alechill / livevalidation

Open source javascript library for slick, powerful, and easy client-side validation.
http://livevalidation.com
Other
151 stars 57 forks source link

Button action wont validate #17

Open ambasador opened 11 years ago

ambasador commented 11 years ago

Hi all,

I've a problem with valid element age on click. I want to check first that element age is valid then load loadresults();, i've tried few option but they dont work, anyone knows how to fix it

$('button').click(function () { loadresults(); }); var age = new LiveValidation('age', { validMessage: "Message ", wait: 1000 }); age.add(Validate.Numericality, { minimum: 18, maximum: 100, onlyInteger: true, notANumberMessage: "Only Numbers" }); age.add(Validate.Presence, { failureMessage: "Error" });

BrianPMucha commented 10 years ago

I think instead of binding to .click on the button you need to use .submit on the form. LV will stop the submit if validation fails.