1000hz / bootstrap-validator

A user-friendly HTML5 form validation jQuery plugin for Bootstrap 3
http://1000hz.github.io/bootstrap-validator
MIT License
2.38k stars 1.07k forks source link

Disabled buttons can still be clicked #602

Open flightsurvey opened 6 years ago

flightsurvey commented 6 years ago

When the OK button is disabled because validation tests have failed it shows as disabled but can still be clicked on.

bertonbeil commented 6 years ago

@flightsurvey add this code to validator.js

Line 294:

   Validator.prototype.toggleSubmit = function () {
    if (!this.options.disable) return
    this.$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())
    // add this line
    this.$btn.attr('disabled', this.isIncomplete() || this.hasErrors())
  }

Line 327:

   this.$btn.removeClass('disabled')
  // and this
   this.$btn.prop('disabled', false) 
utdrmac commented 6 years ago

This needs a PR! Been banging my head against the wall for an hour trying to understand this.

peter450 commented 6 years ago

Adding this to the validator.js works well for me but the div below disappear <div class="help-block with-errors"></div>