garygreen / dominar

Lightweight bootstrap validator inspired by Laravel
http://garygreen.github.io/dominar/
22 stars 4 forks source link

Add validation events (validationFailed/Passed) to use with other triggers, not just submit #25

Closed vlascik closed 8 years ago

vlascik commented 8 years ago

I think it would be helpful if dominar would also have something like dominarValidationPassed / dominarValidationFailed events even without submitting the form, so that users could e.g. disable action buttons if the validation didn't pass. Or maybe this could be achieved in some other way?

garygreen commented 8 years ago

That would be pretty useful. Could add something along the lines of:

var form = document.getElementById('my-form');
var btn = document.getElementById('submit-btn');
form.addEventListener('dominarValidatedField', function(passed, field, dominar) {
    if (dominar.isPassing())
    {
        btn.removeAttribute('disabled');
    }
    else
    {
        btn.setAttribute('disabled', 'disabled');
    }
});
vlascik commented 8 years ago

Sounds good, would dominar.isPassing() mean all fields on a form passing? Would field also have isPassing()?

garygreen commented 8 years ago

Yes, dominar.isPassing() means are all fields passing and the actual result of the field is passes as supplied in the closure. Or could add field.isPasing() as well

On 7 December 2015 at 14:58, vlascik notifications@github.com wrote:

Sounds good, would dominar.isPassing() mean all fields on a form passing? Would field also have isPassing()?

— Reply to this email directly or view it on GitHub https://github.com/garygreen/dominar/issues/25#issuecomment-162548463.

vlascik commented 8 years ago

Ok, great, thanks.

garygreen commented 8 years ago

Closing this in favour of #26