• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 401
  • Last Modified:

MVC 4 Custom Validation

Like most websites that allow a user to create an account will also have them type and re-type the password. I am looking to do this with a Custom Validator. Does anyone have an example?
0
AmbassadorSpock
Asked:
AmbassadorSpock
1 Solution
 
Roopesh ReddyIT AnalystCommented:
Hi,

Check this jQuery validation code -

    $('#btnChange').bind("click", function (event) {
        var txtNewPassword = $('#txtNewPassword').val();
        var txtConfirmNewPassword = $('#txtConfirmNewPassword').val();

        if (txtNewPassword.length <= 0 ||
            txtConfirmNewPassword.length <= 0) {
            event.preventDefault();
        }

        if (txtNewPassword != txtConfirmNewPassword) {
            event.preventDefault();
        }
    });

Open in new window


Hope it helps u...
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now