king-ds
November 28, 2019, 7:16am
1
Hi Guys,
I’m dealing with forms and validators in Ionic but I don’t have any idea on creating a custom validators. Like in my case, I’m planning to make a custom validator to check whether if password and confirm password fields having the same values.
.
Code snippet for registration form.
Note: password_again is confirm password field.
Anyone know how to make a password validator? Thanks
king-ds
November 28, 2019, 7:25am
3
hello here is the code
this.register_form = form_builder.group({
student_number : ['', Validators.required],
clinic_level : ['', Validators.required],
first_name : ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
middle_name : ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
last_name : ['', Validators.compose([Validators.maxLength(30), Validators.pattern('[a-zA-Z ]*'), Validators.required])],
password : [''],
password_again : [''],
});
}
gokujy
November 28, 2019, 7:36am
4
Hello,
check out this answer , he did password and confirm password validation