RegularExpressionValidator for user name

653 views Asked by At

I want to use ASP RegularExpressionValidator to check if the user entered a name which consists of 3-8 characters (English only).
What do I need to write in the ValidationExpression?
I tried this one ^([\S\s]{0,4})$ but it doesnt seem to work... Any ideas?

1

There are 1 answers

1
Anthony Chu On

If you only want to match letters of the alphabet 3-8 characters long try this...

^[a-zA-Z]{3,8}$
  • ^ = start of string
  • [a-zA-Z] = A-Z upper or lower case
  • {3,8} = 3-8 occurences
  • $ = end of string