JQuery Validate Select Element Value (Min/Max length)
Hey everyone,
I am having a hard time understanding a feature in JQuery Validate. Half of me thinks its a bug, half of me think I just dont understand what they are trying to accomplish.
Here is my issue. I want to validate min/max length on the value of a select element. The value of the select element should be a sha1 hash, so it should be 40 characters long. When i validate it, it always returns false. Looking into the source code and following it around, i always get a length of "1", even though i know the value it 40 characters long.
If you look at the source code, here is where the validator on min length gets called
https://github.com/jzaefferer/jquery-validation/blob/master/src/core.js#L1182
and here is the function it calls
https://github.com/jzaefferer/jquery-validation/blob/master/src/core.js#L838
Now, i look at that and think, "well its always going to be 1 because that is how many elements were returned". Its almost as if they need to do
return
$
(
"option:selected"
,
element
).
val().length
;
Here is a JSFiddle with the exact scenario
http://jsfiddle.net/n2ruoLzu/3/
I was just lazy and pasted in the whole library, so you will have to scroll to the bottom, past the library code, to see my javascript code.
Thoughts? Am I just out to lunch on my understanding of how this should work>