验证问题:我想让一个文本框输入的字符串长度在6-16之间,如何用验证控件控制?
验证问题:我想让一个文本框输入的字符串长度在6-16之间,如何用验证控件控制?
net2005开发;
不想用服务器验证,
------解决方案--------------------^.{6,16}$
------解决方案--------------------see
<asp:RegularExpressionValidator ID= "RegularExpressionValidator1 " runat= "server " CssClass= "note " ErrorMessage= "6-16 characters,no spaces " Display= "Dynamic " SetFocusOnError= "True " ControlToValidate= "txtUserPwd " ValidationExpression= "\S{6,16} "> </asp:RegularExpressionValidator>
------解决方案--------------------正则验证控件RegularExpressionValidator的ValidationExpression属性里写上面正则
另外,RegularExpressionValidator不能验证非空,验证非空用RequiredFieldValidator
------解决方案--------------------正则表达式。
------解决方案--------------------使用验证控件 RegularExpressionValidator
<asp:RegularExpressionValidator ID= "RegularExpressionValidator1 " runat= "server " ErrorMessage= "请确保6-16字符 " Display= "Dynamic " ControlToValidate= "YourTextBoxID " ValidationExpression= "\S{6,16} "> </asp:RegularExpressionValidator>