Tuesday, August 10, 2010

How to validate password strength using regular expression

Please note: code being formatted for the demonstration purposes.
<asp:TextBox runat="server" ID="txtMediumPassword" />
        <asp:RegularExpressionValidator runat="server" 
            ErrorMessage="Password should contain minimum 7 non repetitive characters" 
            ControlToValidate="txtMediumPassword" 
            ID="RegularExpressionValidator1" 
            ValidationExpression="^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$" />
<asp:TextBox runat="server" ID="txtStrongPassword" />
<asp:RegularExpressionValidator runat="server" 
    ErrorMessage="
        Password should contain minimum 8 non repetitive characters, 
        at least 1 Uppercase character, at least 1 lowercase character and at least 1 digit." 
    ControlToValidate="txtStrongPassword"
    ID="regexPassword" 
    ValidationExpression="^(?=.{8,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9])))(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).*$" />

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...