无法获取asp.net定期EX pression验证为空白密码的工作? [英] Can't get asp.net regular expression validator to work for blank passwords?
问题描述
我不希望允许空白密码,但如果我离开文本框为空,从常规的前pression text属性显示不出来,直到我输入至少1个字符。我怎么让它不要有空白密码?我试图使用的+号,而不是*符号,但它仍然没有奏效。
< ASP:RegularEx pressionValidator
的ControlToValidate =txtPassword
显示=动态
=服务器
文本=无效
ValidationEx pression =^(?=。* \\ D {1})(?=。* [一个-ZA-Z] {2})。{7,} $
的ValidationGroup =UserRegistrationValidation>
< / ASP:RegularEx pressionValidator>
一个RegularEx pressionValidator犯规验证由设计空文本。您还需要一个RequiredFieldValidator或看看下面的链接:
<一href=\"http://stackoverflow.com/questions/1085464/regularex$p$pssionvalidator-not-firing-on-white-space-entry\">http://stackoverflow.com/questions/1085464/regularex$p$pssionvalidator-not-firing-on-white-space-entry
I do not want to allow blank passwords, but if I leave the textbox blank, the text property from the regular expression does not show up until I enter at least 1 character. How do I allow it not to have a blank password? I tried using the + sign instead of the * sign, but it still did not work.
<asp:RegularExpressionValidator
ControlToValidate="txtPassword"
Display="Dynamic"
runat="server"
Text="Invalid"
ValidationExpression="^(?=.*\d{1})(?=.*[a-zA-Z]{2}).{7,}$"
ValidationGroup="UserRegistrationValidation">
</asp:RegularExpressionValidator>
A RegularExpressionValidator doesnt validate empty text by design. You need also a RequiredFieldValidator or have a look at the following link: http://stackoverflow.com/questions/1085464/regularexpressionvalidator-not-firing-on-white-space-entry
这篇关于无法获取asp.net定期EX pression验证为空白密码的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!