Answer the question
In order to leave comments, you need to log in
Why is angular ignoring the validator?
this.myform = new FormGroup({
'name': new FormControl('', [
Validators.required,
Validators.minLength(3),
Validators.maxLength(20)
]),
'email': new FormControl('', [
Validators.required,
Validators.email
]),
'password': new FormControl('', [
Validators.required,
Validators.pattern(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/)
]),
'password_repeat': new FormControl('', [
Validators.required
])
}, this.passwordMatchValidator)
Answer the question
In order to leave comments, you need to log in
this.myform = new FormGroup({ though it should, use this.formBuilder.group
constructor(private formBuilder: FormBuilder) {}
ngOnInit() {
this.myform = this.formBuilder.group({
name: new FormControl('', [.....
....
}, {
validator: myComponent.myGroupValidator
})
}
static myGroupValidator(control: AbstractControl): { [key: string]: boolean } | null {
// тут в дебаге проверьте, что заходит сюда
....
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question