VeroLom
VeroLom

Reputation: 3934

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?

Upvotes: 0

Views: 349

Answers (1)

Njuguna Mureithi
Njuguna Mureithi

Reputation: 3856

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

Upvotes: 1

Related Questions