-
Notifications
You must be signed in to change notification settings - Fork 331
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
Use validation outside the context of a form #43
Comments
Because it was only supposed to be for forms ;) Unfortunately, you do need to 'set up' the field first (if you've copy-pasted step 2 from the installation in the docs, your fields should already be set up), but you can do something similar to what you've asked: var $inputs = $("#my-text-field");
$inputs.jqBootstrapValidation(); // set up; ideally only called on each field once
// triggers the field(s) to show the error-state if something is wrong
$inputs.trigger("change.validation", {submitting: true}); If you want to do something with the error messages but not display them in help-blocks, you can also get them with collectErrors: var errors = $("...").jqBootstrapValidation("collectErrors");
// {
// "username": ["...", "..."],
// "password": ["...", "..."]
// } I'll mark this as an enhancement request too, it would make sense for it to be easier. |
Awesome, thanks! |
I'd like to second the enhancement request. E.g., I'm trying to use this w/ Meteor.js and forms aren't really "submitted". You catch the click event on the submit button, then do an ajax call to call a web method, then do a return false to prevent the click from doing the actual submit. |
Yes, this enhancement would be great to have! |
+1 for adding this feature |
jqBootstrapValidation seems to only work inside the context of a form submit. But this does not work well with some use cases. Why can't I validate a single component any time I want? something like:
$('#my-text-field').jqBootstrapValidation('validate');
To have the validation error show for that component?
The text was updated successfully, but these errors were encountered: