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.

1 Answer 1

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","");
        }
    }



});
Sign up to request clarification or add additional context in comments.

3 Comments

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?
learn the javascript oops.And try to dig into the validation plugin code. you may get some idea.
it appears that you're overriding the unhighlight function?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.