Validate Password Confirmation

form validation

Validate Password Confirmation

by dantan on Tue Aug 05, 2008 8:49 am

I am not that firm in js - maybe someone has done something like that.

I need to check that if someone changes a password, compare it to the confirmation input-field.

Thanks for help
dantan
 
Posts: 1
Joined: Tue Aug 05, 2008 8:47 am

Re: Validate Password Confirmation

by polak25 on Thu Aug 07, 2008 9:29 am

Hello,

I am also looking for a validation of password

if you have found, thank you for giving us the code.

Otherwise, I hope someone will help.

Thank you
Merci,

Fabien URBANIK
polak25
 
Posts: 2
Joined: Thu Aug 07, 2008 9:27 am
Location: France, Besançon

Re: Validate Password Confirmation

by tobillo on Tue Aug 19, 2008 9:52 am

just add in validation.js on Line 84

switch(el.type){
case 'text':
case 'password':
case 'textarea':
case 'select-one':

---------
if you want to check the lenght of a string (e.g. Password must have min. 6 Signs) create a class and add it between the switch:
Code: Select all
if(el.hasClass('string6')){
                  if(el.value.length < 6){
                     valid = false;
                     this.setMsg(el, 'Bitte min. 6 Zeichen eingeben');
                  }else{
                     valid = true;
                  }
               }


just add "string6" to the input and go ...

Regards

Oliver
tobillo
 
Posts: 1
Joined: Tue Aug 19, 2008 9:48 am

Re: Validate Password Confirmation

by polak25 on Tue Aug 19, 2008 10:48 am

Good morning,

Above all thank you for having responded to my message.

I do not want to check the length of the password but check if confirmation is the password.

Thank you
Merci,

Fabien URBANIK
polak25
 
Posts: 2
Joined: Thu Aug 07, 2008 9:27 am
Location: France, Besançon

Re: Validate Password Confirmation

by alexb on Sun Sep 07, 2008 9:43 am

I am no javascript guru but I have managed to get this working.

Firstly you can only confirm against a password field with the name 'password'. Follow the previous instructions in this post to apply the character limit validation.

In your form create you password confirmation field and give it a class of 'required confirm'.

Now go to validate.js and add the following after the password length check if statement:

Code: Select all
               
               if(el.hasClass('confirm')){
                  if(el.value != $('password').value){
                      valid = false;
                      this.setMsg(el, 'Passwords do not match');
                    }else{
                      valid = true;
                    }
               }


This works fine for me and will give password length validation as well as confirmation checking.

I was looking around for this for a little while so thought I'd share!

Cheers
alexb
 
Posts: 1
Joined: Sun Sep 07, 2008 9:37 am


Return to validate

Who is online

Users browsing this forum: Alexa [Bot] and 0 guests