Skip to content
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

Making a chosen input a required field #496

Closed
jbrooksuk opened this issue Feb 14, 2012 · 6 comments
Closed

Making a chosen input a required field #496

jbrooksuk opened this issue Feb 14, 2012 · 6 comments

Comments

@jbrooksuk
Copy link

My original markup sets the select to be a required field, however Chosen doesn't seem to comply to that?

@tdm00
Copy link

tdm00 commented Dec 10, 2012

@jbrooksuk did you ever find a solution for this? jQuery Validate doesn't seem to allow me to force the field to be required either.

@CaptainN
Copy link

CaptainN commented Apr 2, 2013

I have a patch to this referenced in #515 and pull request in #900.

@jbrooksuk
Copy link
Author

I ended up writing a helper function which performs this check manually on chosen elements. I'll dig it out tomorrow if I can find it, although in the mean time @CaptainN's solution looks good 👍

@kenearley
Copy link

This is a dupe of #515. We wil be following up there. Thanks.

@jbrooksuk
Copy link
Author

#515 is technically a dupe of this, but yeah okay.

@tripflex
Copy link

If you're using Chosen for all select elements, you can use this CSS to change make it visible (to DOM), but no opacity, no height, absolute position.

These CSS selectors target invalid select elements, with one of them targeting multiple adding a 15px margin-top to center it on the multiselect elements.

select:invalid {
	height: 0px !important;
	opacity: 0 !important;
	position: absolute !important;
	display: flex !important;
}

select:invalid[multiple] {
  	margin-top: 15px !important;
}

Demo: http://jsfiddle.net/tripflex/2zdeu9oc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants