Kalaiarasan Manimaran
Kalaiarasan Manimaran

Reputation: 1658

A Very Basic Confirm password validation not working

Can anyone solve this fiddle. it has two fields password and confirm password. Validation needs to be done such that both password entered should be the same.

$(document).ready(function ()
{
    $('#EditForm').validate({ 
        rules: {
            password: {
                required: true
            },
            cpassword: {
                required: true,
                equalTo: "#password"
            }
        }
    });
});

http://jsfiddle.net/kalai789/aCZgK/2/

Thanks in advance

Upvotes: 1

Views: 533

Answers (3)

Dr. Rajesh Rolen
Dr. Rajesh Rolen

Reputation: 14285

Found similar question

Demo

jQuery('.validatedForm').validate({
    rules : {
        password : {
            minlength : 5
        },
        password_confirm : {
            minlength : 5,
            equalTo : "#password"
        }
    }
});

Upvotes: 1

Rory McCrossan
Rory McCrossan

Reputation: 337570

Firstly the external version of jQuery you had loaded was very old (1.5.2) it appears incompatible with the current version of validate, I updated the fiddle to use 1.6.4 as that was the lowest available on jsFiddle. Secondly, the rules and other settings for the validate plugin are keyed on the name attribute of the element, not the id, so they need to be added:

<input type="password" name="password" id="password"/>
<input type="password" name="cpassword" value="" id="cpassword"/>

Working fiddle

Upvotes: 3

X-Pippes
X-Pippes

Reputation: 1170

use keyup method

http://jsfiddle.net/dbwMY/

check the info source https://stackoverflow.com/a/9717796/1768043

Upvotes: 2

Related Questions