1

I want to globally change the pattern that angular.js uses to validate email fields.

By default it says that this is valid:

somone@domain

I want to modify it to require the presence of a tld

Does angular expose a global config setting for this?

Christian Schlensker
  • 21,708
  • 19
  • 73
  • 121
  • Maybe this will help: http://stackoverflow.com/questions/12581439/how-to-add-custom-validation-to-an-angular-js-form – pje Jul 10 '14 at 17:26

1 Answers1

0

There are three options available: to change EMAIL_REGEXP variable in angular.js file (this variable doesn't exposed), apply pattern validator or implement custom validator. The second IMO metter way:

<div ng-form='myForm' >
  <input type='email' name='email' ng-model='email' ng-pattern='/tld/i' />
  <span ng-show='myForm.email.$error.email' >Invalid email address</span>
  <span ng-show='myForm.email.$error.pattern' >Only corporate email addresses accepted</span>
</div>
Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68