开发者

How to force user to type more than any number of characters in password field

I want to force user to type more than 6 characters in password field.we cannot usee range validator because password c开发者_Python百科haracters can be mix(i.e.Numeric or alphabates or special characters)


You can use a RegularExpressionValidator if you're using validators for other things, might as well stay with that:

<asp:RegularExpressionValidator ID="valMinLength" runat="server"
 ControlToValidate="myPasswordBox"
 ErrorMessage="Password should have at least 6 characters"
 ValidationExpression="/{6,}/" />


You can use a RegEx validator that it must match the pattern

[^\s]{6,}


Try using CustomValidator

<script  runat="server">
bool CheckPasswordLen()
{
   if (textbox1.Text.Length < 6)
    return false;
   else
    return true;
}     

</script>     



<asp:textbox id="textbox1" runat="server">
<asp:CustomValidator id="valCustom" runat="server"
    ControlToValidate="textbox1"    
    OnServerValidate="CheckPasswordLen"
    ErrorMessage="*Password must be greater than 6 characters"*
</asp:CustomValidator>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜