11import { Component } from '@angular/core' ;
22import { NavController , NavParams } from 'ionic-angular' ;
3- import { Validators , FormBuilder , FormGroup } from '@angular/forms' ;
3+ import { Validators , FormBuilder , FormGroup , FormControl } from '@angular/forms' ;
4+ import { PasswordValidator } from '../../validators/password.validator' ;
45
5- /**
6- * Generated class for the RegisterPage page.
7- *
8- * See https://ionicframework.com/docs/components/#navigation for more info on
9- * Ionic pages and navigation.
10- */
116
127@Component ( {
138 selector : 'page-register' ,
@@ -16,23 +11,29 @@ import { Validators, FormBuilder, FormGroup } from '@angular/forms';
1611export class RegisterPage {
1712
1813 private validate : FormGroup
14+ submitAttempt : boolean = false ;
1915
2016 constructor ( public navCtrl : NavController , public navParams : NavParams , private fb : FormBuilder ) {
17+
2118 this . validate = this . fb . group ( {
2219 first : [ '' , Validators . compose ( [ Validators . maxLength ( 30 ) , Validators . pattern ( '[a-zA-Z ]*' ) , Validators . required ] ) ] ,
2320 last : [ '' , Validators . compose ( [ Validators . maxLength ( 30 ) , Validators . pattern ( '[a-zA-Z ]*' ) , Validators . required ] ) ] ,
24- email : [ '' , Validators . compose ( [ Validators . email , Validators . required ] ) ] ,
25- password : [ '' , Validators . compose ( [ Validators . minLength ( 6 ) , Validators . maxLength ( 30 ) , Validators . pattern ( '[a-zA-Z ]*' ) , Validators . required ] ) ] ,
21+ email : [ '' , Validators . compose ( [ Validators . required ,
22+ Validators . pattern ( '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$' ) ] ) ] ,
23+ password : [ '' , Validators . compose ( [ Validators . minLength ( 6 ) , Validators . maxLength ( 30 ) , Validators . pattern ( '[a-zA-Z0-9 ]*' ) , Validators . required ] ) ] ,
2624 passwordCheck : [ '' , Validators . required ]
2725 } )
26+
2827 }
2928
3029 ionViewDidLoad ( ) {
3130 console . log ( 'ionViewDidLoad RegisterPage' ) ;
3231 }
3332
3433 regForm ( ) {
34+ this . submitAttempt = true
3535 console . log ( this . validate )
3636 }
3737
3838}
39+
0 commit comments