-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any chance to trigger the validation process manually? #126
Comments
I took a closer look at the code and found the "private" function "_validateForm". I'm using the following jQuery snippet after the first submit attempt. $("input[name^='poll_']").change(function() { validator._validateForm(null); }); Do you have any concerns with this approach? I guess there is a reason why this function is pseudo private. Thanks again! |
I just haven't had time to expose a proper public API to fit this use case. Using _validateForm is fine with the current version, but I would always check when you are upgrading to make sure everything still works as is. I'm pretty swamped right now so I'd be very open to a PR with a better API for this use case. |
I also think that a manual trigger function is a very good idea. ;-) |
Me too. Having a public call to validate the whole form and another to validate just one given field would be super useful. |
I was able to alter validate.js to call it manually as I wanted to integrate field validation with other validation types such as validation that involves more than one field. I did this by creating a wrapper around the call to the validation object. The wrapper is bound to an onclick event. I also had to remove a few lines in validate.js. I removed var _onsubmit = this.form.onsubmit and altered the code below that as well so that the lines below were just an anonymous function that called _validateForm(evt) upon creation of the ValidateForm object. |
i really want a manual trigger too!!! |
what's more , i don't want one with jq |
This commit resolves issue rickharrison#197 might be helpful as a starting point for issue rickharrison#126 Adds a public valididateOne method to the validateForm object which allows you to validate a single field manually. /* Usage */ var valid, field; field = $('[name="name"]).attr('name"); valid = validator.validateOne(field) if(!valid === true){ /* valid === [{name, "name", message="Current error" messages="[Current error, Other errors]"}]
BTW: Thanks for the great work!
The text was updated successfully, but these errors were encountered: