Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

confirm password on keyup (Before form Submit)

Hello All;
I need to check the password and confirmpassword before the user clicks submit.
I have found all sorts of articles, but all of them are on FormSubmit.
I need to check:
Either while the user is typing into the confirm (This is the preferred method)
Once the user finishing typing into the confirmpassword.

Thank You
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

1) Create a basic page with your server side code that will show the id of the row based on the password based on form input.  If using asp request.form not request or request.querystring.
message="No Dice, not here"
' "rs=select * from myContacts where password="&request.form("pass")
if not rs.bof or not rs.eof then
    message="I found it:"&theID
end if
response.write message

Open in new window

2) Jquery ajax

<input type="text" id="pass" name="pass">
<div id="message"></div>

//you will want to do this as a function

var pass=$('#pass').val()

  type: "POST",
  url: "myASPpage.asp",
  data: { pass: pass }
}).done(function( msg ) {


Open in new window

Avatar of Wayne Barron


Hey padas, hope you are doing well.

Unfortunately, I cannot use this.
This is used for a new registration, so there is not database entry for the potential member yet.

I am testing
<input type="password" name="password" />
<input type="password" name="confirmpassword" />

Not against a database entry.
$("#confirmpasswordID").bind("keyup blur, function() {
        if( $("#passwordID").val() == $("#confirmpasswordID").val() ) {
        else {

Open in new window

<input type="password" name="password" id="passwordID" /><span id="spanOrAnyOtherContainerError">bad password</span><br />
<input type="password" name="confirmpassword" id="confirmpasswordID" />

Open in new window
$('#confirm').focusout(function() {
   var pass=$('#password').val();
   var conf=$('#confirm').val();
   if (pass!=conf){
      $('#messg').html('Password does not match');

Open in new window

  <input type="password" id="password" name="password" />
<input type="password" id="confirm" name="confirmpassword" />
  <div id="messg"></div>

Open in new window

Hello Leak.
I am unable to get your code to work.
Also, the
<span id="spanOrAnyOtherContainerError">bad password</span>
Is this not supposed to be invisible until it is called?
I tested the link, and if I type in identical entries, it states that it is
Password does not match
code corrected here :

@padas, sorry did not saw your posts before...
Everyone is welcome to join in on the fun.
I like your code, however, I am trying to make it show ONLY if the passwords are different.
So, I changed the

        else {

<span id="spanOrAnyOtherContainerError" style="display:none;">

This works, but it shows really fast, than it disappears again.
I would like have it only show, if it is different.
work fine for me here :
Once you start typing in the first field, the "bad password" shows.
It needs to only show if it is bad, not when the other field is empty.
Avatar of leakim971
Flag of Guadeloupe image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Leak, I gave you the points, as your code got me where I needed to be at.
I also added in my last code as assisted.

Have a good one.
thank you
your welcome leak, and thank you.
Have an awesome rest of the week.