how to write a reusable ng-pattern?

126 views
Skip to first unread message

Yehonathan Sharvit

unread,
Dec 3, 2014, 6:25:07 AM12/3/14
to ang...@googlegroups.com
In several places in my application I have to validate that a field is a valid french phone number.
Like this:


<input type="text" ng-pattern="/^0[1-6]{1}((([0-9]{2}){4})|((\s[0-9]{2}){4})|((-[0-9]{2}){4}))$/">


* How could I make the regular expression reused by several input fields in my application without copy/pasting the `regex`?

* How could I localize the `regex`?

Justin Walsh

unread,
Dec 4, 2014, 1:22:25 AM12/4/14
to ang...@googlegroups.com
Hi Yehonathan 

Something like this?

Regards
Justin

Yehonathan Sharvit

unread,
Dec 7, 2014, 11:26:52 AM12/7/14
to ang...@googlegroups.com, ang...@googlegroups.com
Thanks Justin. It’s perfect.


Sent from Mailbox


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/fO99gQryUIo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages