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
  • 166,785
  • 24
  • 204
  • 249
Jason Spence
  • 427
  • 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
  • 166,785
  • 24
  • 204
  • 249