Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hii I am new to angular JS

I wanted to know How to write regular expression validators in angular js
for email and 10 digit Mobile number.

any help in this regard is highly appeciated.

Thank you..:)
Posted
Updated 30-Jun-15 20:36pm
v2

1 solution

You can apply a regex to an input field using the ng-pattern attribute, and other validators are available as well (min/max length, required). You can also attach custom validation logic to the ng-change event should you need to.

Have a look at the documentation for input:
https://docs.angularjs.org/api/ng/directive/input[^]

And a working sample on CodePen:
http://codepen.io/astockwell/pen/JyCva[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900