使用所述控件来验证ASP.NET TextBox,我很好奇最流行的做法是什么.目前使用:
ValidationExpression="^[\w\d\s.,"'-]+$"
Run Code Online (Sandbox Code Playgroud)
任何更短的方式这样做?试过\,""无济于事.谢谢.
我做了这个正则表达式:
^[a-zA-Z0-9_.-]*$
Run Code Online (Sandbox Code Playgroud)
支持:
letters [uppercase and lowercase]
numbers [from 0 to 9]
underscores [_]
dots [.]
hyphens [-]
Run Code Online (Sandbox Code Playgroud)
现在,我想添加以下内容:
spaces [ ]
comma [,]
exclamation mark [!]
parenthesis [()]
plus [+]
equal [=]
apostrophe [']
double quotation mark ["]
at [@]
dollar [$]
percent [%]
asterisk [*]
Run Code Online (Sandbox Code Playgroud)
例如,此代码仅接受上面的一些符号:
^[a-zA-Z0-9 _.,-!()+=“”„@"$#%*]*$
Run Code Online (Sandbox Code Playgroud)
返回:
警告:preg_match():编译失败:偏移量为16的字符类中的范围乱序