VeroLom VeroLom - 6 months ago 12
Javascript Question

Jquery Validation plugin - input event

I'm using https://jqueryvalidation.org/ plugin for form validation.
I need to enable/disable submit button depending on form validation result.
How to do it?

Answer
  1. First you need to disable the button
  2. Listen to all Changes in the form

    $( "#myform :input" ).on('change', function(){
        var form = $( "#myform" );
        form.validate();
        if(form.valid())
            $('button).attr("disabled", false);
     });