chosen
chosen copied to clipboard
validation popup not connected to chosen field
If I leave a required* "chosen" field blank I don't get a proper validation error:
- In Firefox 50.1: the validation error pops up in the top right corner of the window instead of attached to the chosen field. "Please select an item from the list"
- In Chrome 52.0: the validation doesn't appear at all.
Is there a way to fix this?
I confirm the problem.
this is because the native validation happens on the original <select>
, not on the chosen UI. and this select is hidden (btw, chrome logs an error about the field not being focusable).
I don't have a fix for it. What I do is that I remove the required
attribute of the select when applying chosen on it (relying on my backend validation alone to validate it as required)
A pretty good solution was provided in https://github.com/harvesthq/chosen/issues/473#issuecomment-10331724
$.validator.setDefaults({ ignore: ":hidden:not(select)" })
It seems that this one can be closed now.