Search the Community
Showing results for tags 'addmethod'.
-
Hello all! I've written a jQuery addMethod for the jQuery validation plugin that seems to be causing an error. Basically this method just checks the db to see if the email address is registered. It works correctly and prompts the error/or passes it correctly. However it fired back an error and sets the focus to the field on submit. If I take this out, the form fires correctly no problem. Any insight I would appreciate. Submit Handler: submitHandler: function(form) { if($("#registerForm").valid()) { $.ajax({ type: "POST", async: false, url: "activate.php", data: $("#registerForm").serialize(), success: function(data) { $('#results').html(data); $('#registerForm').fadeOut(1000); $('#thanks').fadeToggle(1000); } }) } }, addMethod $.validator.addMethod("checkEmailAvailability", function(email) { $('#email').blur(function() { $.ajax({ type: "POST", url: "http://"+location.host+"/includes/checkemail.php?", data: "email=" +$("#email").val(), success: function(data) { if(data == 'false') { //$('#checkEmail').removeClass("validate-ok"); $('#checkEmail').addClass("validate-error").html('✗ ' + $("#email").val() + ' is already a registered email.'); } else { $('#checkEmail').html(''); } } }) }); });