chosen icon indicating copy to clipboard operation
chosen copied to clipboard

validation popup not connected to chosen field

Open tylerecouture opened this issue 8 years ago • 3 comments

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?

tylerecouture avatar Dec 23 '16 21:12 tylerecouture

I confirm the problem.

bvrignaud avatar Jan 19 '17 13:01 bvrignaud

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)

stof avatar Jan 19 '17 13:01 stof

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.

svtux avatar Sep 02 '19 15:09 svtux