Validate strong password using RegularExpressionValidator in asp.net C#

Case1:-

Validate at  least 6 character with characters,numbers,1 upper case letter and special characters  password
Source Code:-

        <asp:TextBox ID="txtpwd" runat="server" Width="180px"></asp:TextBox>


        <asp:RegularExpressionValidator ID="revpwd" runat="server" ErrorMessage="Choose at  least 6 character with characters,numbers,1 upper case letter and special characters."
            ValidationExpression="(?=^.{6,10}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&amp;*()_+}{&quot;:;'?/&gt;.&lt;,])(?!.*\s).*$"
            ControlToValidate="txtpwd" ForeColor="Red" Style="font-size: small"
            Display="Dynamic"></asp:RegularExpressionValidator>

Out-Put:-







Case2:-

Validate at least one numeric,one alphabet without using special character password
Source Code:-
        <asp:TextBox ID="txtpwd" runat="server" Width="180px"></asp:TextBox>

        <asp:RegularExpressionValidator ID="revpwd" runat="server" ErrorMessage="Choose at  least 6 character,one numeric,one alphabet without special charachter "
            ValidationExpression="(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,10})$"
            ControlToValidate="txtpwd" ForeColor="Red" Style="font-size: small"
            Display="Dynamic"></asp:RegularExpressionValidator>


Out-put




Case3:-

Validate at least one numeric,one alphabet and one special character password

Source Code:-

 <asp:TextBox ID="txtpwd" runat="server" Width="180px"></asp:TextBox>
        <asp:RegularExpressionValidator ID="revpwd" runat="server" ErrorMessage="Choose at  least 6 character,one numeric,one alphabet and one special character."ValidationExpression="(?=^.{6,10}$)(?=.*\d)(?=.*[a-zA-Z])(?=.*[!@#$%^&amp;*()_+}{&quot;:;'?/&gt;.&lt;,])(?!.*\s).*$"
 ControlToValidate="txtpwd" ForeColor="Red" Style="font-size: small" Display="Dynamic"></asp:RegularExpressionValidator>


Out-put:-




Validate strong password using RegularExpressionValidator in asp.net C# Validate strong password using RegularExpressionValidator in asp.net C# Reviewed by NEERAJ SRIVASTAVA on 10:47:00 AM Rating: 5

No comments:

Powered by Blogger.