Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular JS Email Validation with unicode characters

I have a sign up form for an application, and angular js is responsible for its validation.

I ran into an issue when Angular js wasn't accepting an email address which has apostrophe in it. "Pear'[email protected]" .

I found out that angularJs doesnt like unicode characters in email address.

Has anyone else came across an issue like this, I am interested in knowing my options to get away with this bug in angularJs.

Any inputs are appreciated. Thanks !

like image 857
Nanu Avatar asked May 31 '13 18:05

Nanu


1 Answers

If having html5 <input type=email /> is not critical, you can use <input type=text /> and pattern validation

 <input type="text" ng-model="field" ng-pattern="EMAIL_REGEXP" />

and you can use regex that @Andy Joslin posted in his answer

 $scope.EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
like image 133
vittore Avatar answered Sep 29 '22 22:09

vittore