开发者

need a regular expression without space and minimum 5 characters, max 20

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}$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜