1

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.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
Jason Spence
  • 472
  • 5
  • 16

1 Answers1

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