开发者

How to tell my RegularExpressionValidator to allow Numbers, Letters, and Spaces only?

开发者 https://www.devze.com 2023-02-07 13:43 出处:网络
I am using: ValidationExpression=\"^[0-9开发者_Go百科a-zA-Z]+$\" to try and only allow letters and numbers with no symbols.

I am using: ValidationExpression="^[0-9开发者_Go百科a-zA-Z]+$" to try and only allow letters and numbers with no symbols.

Yet when I enter a phrase into the box that includes a space, it fails to validate. So I'm guessing I need to explicitly allow spaces too? Example of a search that is not working:

"Summer holiday"


Just add the space?

^[0-9a-zA-Z ]+$


very easy:-

\w+[a-zA-Z\s]+$ for Characters only

\w+[0-9a-zA-Z\s]+$ Alpha Numeric


You must include in [..] spaces. Space, tabulate, etc.. have symbol \s, so you regex: ^[0-9a-zA-Z\s]+$

0

精彩评论

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

关注公众号