I have a very simple form with this regex pattern set on my first/last name fields ng-pattern="/^[a-zA-z]{2,30}$/"
and both fields accept this value as being valid e.g. Tester\^*&^%
. The first/last name should only accept alpha character a-zA-Z with a minimum of 2 characters and a max of 30.
Asked
Active
Viewed 1,119 times
1

Avinash Raj
- 172,303
- 28
- 230
- 274

Jason Spence
- 472
- 5
- 16
-
Why we care about attention? I just asked a question about this on meta.. – Avinash Raj Feb 12 '15 at 18:20
1 Answers
0
Here is the wrong thing.
^[a-zA-z]{2,30}$
^
|
It would match \^
symbols because these symbols are comes under the range from A
to z
.
Modified regex.
^[a-zA-Z]{2,30}$

Avinash Raj
- 172,303
- 28
- 230
- 274
-
1Awesome, thank you! Sometimes you're working so fast you can't see the answer right in front of you. – Jason Spence Oct 16 '14 at 17:43