我正在使用ASP ChangePassword控件来帮助用户更改密码,我注意到当我填写表单然后单击“更改密码”时,某些密码不会改变,这是因为它们至少不包含1个非字母数字字符,我认为这是默认行为。
所以我添加了以下内容:
<asp:RegularExpressionValidator
ID="ProgrammaticID"
ControlToValidate="NewPassword"
ValidationExpression='^[a-zA-Z]\w{3,14}$'
ErrorMessage="The password's first character must be a letter, it must contain at least 4 characters and no more than 15 characters and no characters other than letters, numbers and the underscore may be used"
Text="The password's first character must be a letter, it must contain at least 4 characters and no more than 15 characters and no characters other than letters, numbers and the underscore may be used"
ForeColor="red"
BackColor="white"
runat="server"></asp:RegularExpressionValidator>
验证在实际弹出窗体中按预期工作,但是,如何更改实际控件的默认验证以匹配我想要的,而不是控件想要的?
我在属性中找不到任何内容,我猜测默认规则是什么,我的RegularExpressionValidator是无效的,直到我可以使控件遵循这些规则而不是提交,即使验证没有通过。
答案 0 :(得分:1)
你在找错了地方。您不需要使用正则表达式来更改该行为。我相信它是在web.config中设置的
minRequiredNonalphanumericCharacters =“1”
<membership>
<providers>
<add name="AspNetSqlMembershipProvider"
minRequiredNonalphanumericCharacters="1"
... />
</providers>
</membership>