Sign-in Form - Angular Implementation
let url = window.location.href;
if(url.includes('localhost')) {
this.loginForm.patchValue({
email : 'test@gmail.com',
password:'password'
})
}
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
loginForm: FormGroup;
constructor(private formBuilder: FormBuilder,){
this.initForm();
}
initForm(){
this.loginForm = this.formBuilder.group({
email: ['',[]], //Validators.required, Validators.minLength(5),Validators.pattern(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/i)
phone:['',[]], //[Validators.required, Validators.pattern(/^[0-9]*$/),Validators.maxLength(17),Validators.maxLength(7)]
password: ['', []] //Validators.required
});
}
get f() {
return this.loginForm.controls;
}
Comments
Post a Comment