bootstrap-validator
bootstrap-validator copied to clipboard
Display error message bug on validation of input type hidden
I have necessity to validate an hidden field that i populate with a value with jquery event. The validation is forced by adding the data-validate="true" but the help-block was not filled with the error message so it's impossible for the user to see why the form didn't submit.
Here in JS fiddle a fast example:
https://jsfiddle.net/andrea_86/5n2hex6h/
How can fix this?
I'm not able to force the validation by adding data-validate="true"
on the type="hidden"
input field, nor using $.fn.validator.Constructor.INPUT_SELECTOR
, so I can't repro your issue...
Instead, I try <input class="hidden" type="text" ...>
and (I think) it works well.
I had the same issue. Using class="hidden"
and type="text"
(or your preferred type) I got the validator to validate the input.
To make it aware of a value change made by jQuery we used .trigger('change')
on the input.
Would be better if it would be possible out of the box, but works like a charm.