Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9061189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:25:19+00:00 2026-06-16T15:25:19+00:00

I am using http://bassistance.de/jquery-plugins/jquery-plugin-validation/ to validate a form which will allow a user to

  • 0

I am using http://bassistance.de/jquery-plugins/jquery-plugin-validation/ to validate a form which will allow a user to change their existing settings. The form has a field for a password as well as a field to confirm the password. To leave the password unchanged, I instruct the user to leave it blank (maybe some more intuitive way to do this?), and the confirm password field is only shown if the user changes his/her password.

It works pretty well, but has two problems. First, if you enter something in the password field and press tab, you don’t go to the confirm password field, but the next field after that. Second, if you enter something in the password field and press enter, the form is submitted before the confirm password is checked. For some reason, this second deficiency doesn’t manifest using the jsfiddle demo http://jsfiddle.net/4htKu/2/, but it does on the second identical demo http://tapmeister.com/test/validatePassword.html. The code below is identical to the previous two mentioned demos. I believe the problems relates to the confirm_password password being hidden, but am not certain. What do I need to do to fix these two problems? Thank you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <title>jQuery validation plug-in - main demo</title>

        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(function() {

                $("#confirm_password").parent().hide();
                $("#password").val('').
                blur(function() {
                    $t=$(this);
                    if($.trim($t.val())!="" && !$t.hasClass('error')) {$("#confirm_password").parent().show();}
                    else if($.trim($t.val())=="") {$("#confirm_password").val('').parent().hide();}
                });

                // validate signup form on keyup and submit
                $("#signupForm").validate({
                    rules: {
                        firstname: {required: true,minlength: 2},
                        lastname: {required: true,minlength: 2},
                        username: {required: true,minlength: 2},
                        password: {required: true,minlength: 2},
                        confirm_password: {required: true,minlength: 2, equalTo: "#password"}
                    },
                    messages: {},
                    submitHandler: function(form) {alert("submitted");}
                });

            });
        </script>

    </head>
    <body>

        <form class="cmxform" id="signupForm" method="get" action="">
            <fieldset>
                <legend>Validating a complete form</legend>
                <p>
                    <label for="firstname">Firstname*</label>
                    <input id="firstname" name="firstname" />
                </p>
                <p>
                    <label for="lastname">Lastname*</label>
                    <input id="lastname" name="lastname" />
                </p>
                <p>
                    <label for="username">Username*</label>
                    <input id="username" name="username" />
                </p>
                <p>
                    <label for="password">Password (Leave blank to remain unchanged)</label>
                    <input id="password" name="password" type="password" />
                </p>
                <p>
                    <label for="confirm_password">Confirm password</label>
                    <input id="confirm_password" name="confirm_password" type="password" />
                </p>
                <p>
                    <label for="other">Other Non-required</label>
                    <input id="other" name="other" />
                </p>
                <p>
                    <input class="submit" type="submit" value="Submit" />
                </p>
            </fieldset>
        </form>

    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:25:20+00:00Added an answer on June 16, 2026 at 3:25 pm

    Instead of using .blur, use .keydown and a settimeout to detect if the value is blank. If it isn’t blank, show it, else, hide it.

    $("#password").keydown(function() {
        var self = this, $self = $(this);
        setTimeout(function(){
            if ( $.trim(self.value) != "" && !$self.is(".error") ) {
                $("#confirm_password").parent().show();
                return;
            }
            $("#confirm_password").val('').parent().hide();
        },0);
    });
    

    As far as pressing enter, isn’t that what it’s supposed to do? submit the form?

    The reason using .blur doesn’t work is you are tabbing to the next field before the hidden field is shown. This code fixes that problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using this plug in to validate a form http://bassistance.de/jquery-plugins/jquery-plugin-validation/ I've got 3 fields,
I'm using the validate plugin from http://bassistance.de/jquery-plugins/jquery-plugin-validation/ What i'm trying to find is a
I am using asp.net mvc 2.0 and jquery validate 1.7 ( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) What
I have been using jquery validate plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/ . It has been working successfully,
Hi I am using jquery 1.4.2 and jquery validate 1.7( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) Say I
I am using jQuery Validate Plugin found from below URL http://bassistance.de/jquery-plugins/jquery-plugin-validation/ I just wanted
I'm using a great jQuery contact form validator from bassistance (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) is exactly what
Fields on the site are validated using JQuery Validate: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ When there's one e-mail,
I'm using jQuery Validate Plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ Simple demo: <input type=text name=email class=required email />
I am using jQuery validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) Following code is a part of form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.