pramodtech
pramodtech

Reputation: 6280

ASP.NET MVC3 compare validator not working

I have set compare attribute for comparing passwords as explained in this blog. But it's not working. When I googled about it I found that it's a known bug in jquery.validate.js file.

Is the Compare Validator Bugged

Asp.net forum

I tried the solutions given in above links but no success.

Upvotes: 1

Views: 784

Answers (1)

dknaack
dknaack

Reputation: 60516

Description

You are mixing server and client side. The DataAnnotation Attribute CompareAttribute works only on server side.

But you can get similar functionality using the jQuery validation plugin.

Sample

$.validator.addMethod("yourMethodName", function(value, element) {
    // compare and return
}

More Information

Check out theese two tutorials.

Upvotes: 1

Related Questions