Closed bendem closed 11 years ago
It might be a bug. I did not tested required on select in my test suite.
Could you copy / paste your code / jsfiddle it?
Best
It works if you put data-required="true" inside the select tag, however you have to get at least one option tag or you'll get an error like "xxx length of null".
Sorry, it works if you put a empty value and data-required="true" in the select tag... But in fact, the state of the select does not update when changing value like other inputs but when submiting the form again.
Please, try to add data-trigger="change"
to trigger a new validation on each select option change.
Like a green background he would say imo.
Also, when you say "state of the select does not update" be aware that the CSS options for select tags are more limited than other input tags, so the issue might be with your CSS styling.
I use the following library to "normalize" select tags and make them behave like other tags (fully customizable) and they work well with parseley with a few tweaks:
http://adam.co/lab/jquery/customselect/
If anyone decides to implement this, post up and I'll share the customizations I did...
My css work fine, and the data-trigger="change" too... Thanks for that reactivity ;-)
Great!
I'll try to add a checkbox example in the demo form on documentation.
Best
[EDIT] keep this issue open until there's the demo on the doc ;)
I just ran into this. Followed the things discussed here but no luck with validation on the select field. I'm using a dropdown for a State selection, and in the select tag I have: data-required="true" data-trigger="change"
@noahlh can you please post your custom select + parsley integration?
@dotcominfo I was running into this issue when using a placeholder as the first option. For example, if you have a dropdown of US states and the first option is something like:
<option>Select a state...</option>
, you need to make sure to explicitly set the value as empty for that first option, e.g.:
<option value="">Select a state...</option>
. Once I did that, the validation worked as expected, meaning the error message was displayed if the default placeholder was selected, and not an actual US state option. For what it's worth, I also used parsely-required="true" and data-trigger="change" on the select tag.
I am using nice select dropdown to customize the select tag. Parsley is not validating with select dropdown when we are using nice select. Please suggest a solution how to use nice select with parsley.
I am using nice select dropdown to customize the select tag. Parsley is not validating with select dropdown when we are using nice select. Please suggest a solution how to use nice select with parsley.
+1
I am using selectric dropdown. Parsley is not validating with select dropdown when using selectric class. Please suggest a solution how to use selectric class with parsley validation.
Config probably needs to be tweaked, since by default Parsley will exclude hidden fields.
If someone needs me to spend time writing a complete solution I'm available for hire.
@dotcominfo I was running into this issue when using a placeholder as the first option. For example, if you have a dropdown of US states and the first option is something like:
<option>Select a state...</option>
, you need to make sure to explicitly set the value as empty for that first option, e.g.:
<option value="">Select a state...</option>
. Once I did that, the validation worked as expected, meaning the error message was displayed if the default placeholder was selected, and not an actual US state option. For what it's worth, I also used parsely-required="true" and data-trigger="change" on the select tag.
This works Perfectly. THanks
Hi guy, at first, thanks for this awesome jQuery plugin...
I tried to make sure that the first option of my select will not passed (it's something to say user to choose an option...) so i put an empty value and tried "data-notblank", "required", "data-regexp" but nothing seems to work at the moment.
I looked in the code but i don't understand all of it ;) is there a simple way to do that ?
Cordially,