1

I want to write a custom validations for my angular2 project. Can you help me, where to write and how to integrate to my components. I tried like this:

function emailValidator(control: FormControl): { [s: string]: boolean } {
    alert('---->'+control.value);
  if (!control.value.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)) {
    return {invalidEmail: true};
  }
}

In console log, it is giving null. Can you help me.. Thanks..

Dev-VKP
  • 119
  • 2
  • 9
  • Look at this : http://stackoverflow.com/questions/34072092/generic-mail-validator-in-angular2/35477490#35477490 – AdrienTorris Nov 15 '16 at 15:05
  • It is working fine. but when I try to do confirmation password validation, then it is not working. I want to access other fields value also with in my custom validation method. Can you let me know, how to fetch..? Thanks.. – Dev-VKP Nov 18 '16 at 06:32

0 Answers0