2

I'm trying to build a form with custom validations, here is an example:

this.registrationForm= fb.group({
  dob: ['', Validators.required],
  email: ['', Validators.compose([Validators.required,  emailValidator])],
  password: ['', Validators.required],
  confirmPassword: ['', Validators.required],
  firstName: ['', Validators.required],
  lastName: ['', Validators.required]
}, {validator: matchingPasswords('password', 'confirmPassword')})

i have only one problem - the ng-invalid css class from the NgModel directive won't fire for the custom validator, anyone encountered with this problem?

1 Answer 1

1

in the CSS file the 'ng-invalid' class associated with [required] so it won't fire without it and the custom Validator is not 'required'. for example:

<input required type=”text” ngControl=”username” />
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.