locked
Compare compare password and confirm password at a time RRS feed

  • Question

  • User-1236024542 posted

    Hello,

    I am designing registration form in ASP.NET using C#. In my Registration Form I have some fields and among them I have two textboxes for password & confirm-password. I am trying to match them at a time. 

    For example, when I type password in "password" textbox and in "confirm-password" textbox. It should compare both password at a same time without clicking on anything OR as soon I jump to next field compare both password and display message if both of them are not same.

    Any Suggestion?

    Thanks,

    Ritul

    Tuesday, March 20, 2018 6:20 PM

Answers

  • User-1716253493 posted

    Bootstrap validator

    http://1000hz.github.io/bootstrap-validator/?underwear=on

    Compare validator

        <asp:CompareValidator ID="CompareValidator1" runat="server" 
            ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="not match">
        </asp:CompareValidator>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 21, 2018 12:25 AM
  • User283571144 posted

    Hi ritul29,

    According to your description, I suggest you could consider using javasript to achieve your requirement.

    You could use jquery keyup method to check the password.

    More details, you could refer to below codes:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
        <script>
            $(document).ready(function () {
                $("#password2").keyup(validate);
            });
    
    
            function validate() {
                var password1 = $("#password1").val();
                var password2 = $("#password2").val();
    
    
    
                if (password1 == password2) {
                    $("#validate-status").text("valid");
                }
                else {
                    $("#validate-status").text("invalid");
                }
    
            }
    
        </script>
    </head>
    <body>
        <input id="password1" type="password" />
        <br />
        <input id="password2" type="password" />
        <p id="validate-status"></p>
    </body>
    </html>

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2018 7:21 AM

All replies

  • Tuesday, March 20, 2018 7:02 PM
  • User-1716253493 posted

    Bootstrap validator

    http://1000hz.github.io/bootstrap-validator/?underwear=on

    Compare validator

        <asp:CompareValidator ID="CompareValidator1" runat="server" 
            ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="not match">
        </asp:CompareValidator>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 21, 2018 12:25 AM
  • User283571144 posted

    Hi ritul29,

    According to your description, I suggest you could consider using javasript to achieve your requirement.

    You could use jquery keyup method to check the password.

    More details, you could refer to below codes:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
        <script>
            $(document).ready(function () {
                $("#password2").keyup(validate);
            });
    
    
            function validate() {
                var password1 = $("#password1").val();
                var password2 = $("#password2").val();
    
    
    
                if (password1 == password2) {
                    $("#validate-status").text("valid");
                }
                else {
                    $("#validate-status").text("invalid");
                }
    
            }
    
        </script>
    </head>
    <body>
        <input id="password1" type="password" />
        <br />
        <input id="password2" type="password" />
        <p id="validate-status"></p>
    </body>
    </html>

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2018 7:21 AM