ppp
ppp

Reputation: 2055

jQuery form validation - Check if emails are the same

I am trying to create a jQuery form validator for my website.

My code is in this fiddle.

The question is, what do I need to do, so that I can check if the email is the same as the email confirmation when both fields have valid email addresses?

Also, since I'm currently learning javascript/jQuery, feel free to point out any mistakes|bad practices on my code.

Upvotes: 0

Views: 2646

Answers (1)

adeneo
adeneo

Reputation: 318182

$("#signupform").on('submit', function(e) {
    var email = $("#email_ID").val(),
        confirm = $("#email_confirm_ID").val();

    if (email!=confirm) {
       alert('email and confirm are not equal!');
       e.preventDefault(); //form will not be submitted
    }
});

Upvotes: 3

Related Questions