casperin / nod

Plugin that gives you frontend validation for forms.
http://casperin.github.io/nod/
381 stars 137 forks source link

submit button not getting disabled #124

Open SingingBush opened 7 years ago

SingingBush commented 7 years ago

In Chrome my submit button isn't getting disabled and in IE it gets disabled but doesn't get enabled when the form is valid. Looking at nod.js it seems that the submitBtn.disabled = is likely to be a problem.

    function toggleSubmit () {
        if (configuration.submit && configuration.disableSubmit) {
            nod.getElements(configuration.submit).forEach(function (submitBtn) {
                submitBtn.disabled = !areAll(nod.constants.VALID);
            });
        }
    }

If the submitBtn is a jQuery element then the disabled attribute should be set with submitBtn.prop( "disabled", true ); and if it's a standard dom element it should be submitBtn.setAttribute("disabled", "true");.

UPDATE

Turns out this is due to the fat that my form is using an a tag for the submit button rather than an actual button. (it's an old JSF app that uses a commandLink to submit the form).

It would be good if nod could disable the element that is specified using the submit option regardless of whether it's a button tag or not.

casperin commented 7 years ago

Hi @SingingBush, I'm no longer actively maintaining this repository; but I'm open for pull requests if you find for it.