I need a regular expression which accepts the alphabets UPPER CASE,lower case and digits minimum character is 5 and maximum character is 20. This is my current R开发者_StackOverflow中文版eg Ex.
^[A-Za-z\d]{5,20}$
The issue that I am facing with the current Regular expression is, if I enter 5 spaces it accepts. so I want the user to enter password without space.
Are you using a RegularExpressionValidator? If so you should add a RequiredFieldValidator to prevent whitespace or blank entries. Per the RegularExpressionValidator documentation:
Validation succeeds if the input control is empty. If a value is required for the associated input control, use a RequiredFieldValidator control in addition to the RegularExpressionValidator control.
another way
^[a-zA-Z0-9]{5,20}$
精彩评论