1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular and froala editor validation with reactive forms

Discussão em 'Angular' iniciado por Iman, Maio 22, 2025.

  1. Iman

    Iman Guest

    I am using Froala Editor with Angular 4 and I am facing some problems with showing the validation message.

    <div class="form-group">
    <label for="jobDescription">Job Description</label>
    <textarea style="height: 300" [froalaEditor] formControlName="jobDescription" name="jobDescription" id="jobDescription" cols="30"
    rows="10" class="form-control"></textarea>
    <div class="text-danger" *ngIf="!jobDescription?.valid && jobDescription.touched">
    <span class="text-danger" *ngIf="jobDescription.errors?.required">Job Description is Required.</span>
    </div>
    </div>


    I want to show the validation message only when the field is touched. However the touched state doesn't become true. If I remove jobDescription.touched from *ngIf then when the field is empty, validation message is shown. The problem is that the validation message is there from the beginning (before the field is even touched). Any idea how to fix this? This is how my .ts file looks.

    export class JobFormComponent {
    form = new FormGroup({
    jobDescription: new FormControl('', Validators.required),
    ...
    ...
    });

    get jobDescription() {
    return this.form.get('jobDescription');
    }
    }

    Continue reading...

Compartilhe esta Página