1

I am having an issue with the JQuery Validation Plugin. I'm using it on a rails form, and I have validation working on clicking the submit button. The issue is that once the validation errors are fixed the submit button does not come back from being disabled, and even with the submitHandler as

$.validator.setDefaults({ submitHandler: function(form) { form.submit(); } });

the form won't submit. I know there's got to be something I'm missing. The form will submit if there are no validation issues. I've checked out some of the other messages here about this issue but the onclick and onkeyup stuff doesn't work.

brianfoshee
  • 37
  • 1
  • 7

1 Answers1

2

Try this

var validator = $("#signupForm").validate({
    rules: {

    },
    messages:{

    },
    unhighlight: function( element, errorClass, validClass ) {
        $(element).removeClass(errorClass).addClass(validClass);
        if(validator.numberOfInvalids() == 0){
            $("#SubmitButton").attr("disabled","");
        }
    }



});
RSK
  • 17,210
  • 13
  • 54
  • 74
  • Perfect! It worked. If there's any way you can explain the unhighlight: part, and where the function variables (element, errorClass, validClass) come from that'd be awesome. I'm getting started with JS, so bare with me. I understand the rest of the function, but is unhighlight called from the validator somehow? – brianfoshee Dec 14 '10 at 16:55
  • learn the javascript oops.And try to dig into the validation plugin code. you may get some idea. – RSK Dec 14 '10 at 17:34
  • it appears that you're overriding the unhighlight function? – brianfoshee Dec 14 '10 at 17:38