ng-pattern not working

30 views
Skip to first unread message

Rajan Singh

unread,
Jul 26, 2016, 10:54:59 AM7/26/16
to AngularJS
Hi,

I have pattern  which is  /^\w(?:(?![ \\.']{2,})[\w \\.'])*/. It is for name which starts with words & allows .(period), (space), '(Single Quote) but two consecutive .(period), (space), '(Single Quote) are not allowed.

I am using ng-pattern= /^\w(?:(?![ \\.']{2,})[\w \\.'])*/ which is not working allowing @! anything. I don't know why it is happening. Please help.

Positive test cases :  A.B Shar'ma
                                  He.llo's

Negative Test Cases: He.llo's@@#!
                                   ...Raj
                                   '''MyName@!

If you want build you own test case, Please enter a valid name. Special characters other than (Space, Dot and Single Quote) are not allowed.

Currently I am using Angular version 1.5.3;

Lucas Lacroix

unread,
Jul 26, 2016, 10:56:55 AM7/26/16
to ang...@googlegroups.com
This seems like an issue with regex.

I would try out a service like this: https://regex101.com/

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
Lucas Lacroix
Computer Scientist
System Technology Division, MEDITECH

Rajan Singh

unread,
Jul 26, 2016, 12:45:15 PM7/26/16
to AngularJS
I have already verified regex on http://regexr.com/ & now verified on https://regex101.com/  It  is a valid regex.

Lucas Lacroix

unread,
Jul 26, 2016, 12:49:57 PM7/26/16
to ang...@googlegroups.com
In Angular2, there is a PatternValidator directive. Not sure if there is an equivalent directive for Angular1. Sorry I can't be of more help.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages