* Simplified select validation, delegating to jQuery's val() method to get the select value; should fix http://plugins.jquery.com/node/11239

This commit is contained in:
Jörn Zaeffferer
2009-11-23 22:20:29 +00:00
parent d98ab2d886
commit d35485a378
2 changed files with 4 additions and 2 deletions

View File

@@ -10,6 +10,7 @@
* Improved interactive select validation, now validating also on click (via option or select, inconsistent across browsers); doesn't work in Safari, which doesn't trigger a click event at all on select elements; fixes http://plugins.jquery.com/node/11520 * Improved interactive select validation, now validating also on click (via option or select, inconsistent across browsers); doesn't work in Safari, which doesn't trigger a click event at all on select elements; fixes http://plugins.jquery.com/node/11520
* Updated to latest form plugin (2.36), fixing http://plugins.jquery.com/node/11487 * Updated to latest form plugin (2.36), fixing http://plugins.jquery.com/node/11487
* Bind to blur event for equalTo target to revalidate when that target changes, fixes http://plugins.jquery.com/node/11450 * Bind to blur event for equalTo target to revalidate when that target changes, fixes http://plugins.jquery.com/node/11450
* Simplified select validation, delegating to jQuery's val() method to get the select value; should fix http://plugins.jquery.com/node/11239
1.5.5 1.5.5
--- ---

5
jquery.validate.js vendored
View File

@@ -889,8 +889,9 @@ $.extend($.validator, {
return "dependency-mismatch"; return "dependency-mismatch";
switch( element.nodeName.toLowerCase() ) { switch( element.nodeName.toLowerCase() ) {
case 'select': case 'select':
var options = $("option:selected", element); // could be an array for select-multiple or a string, both are fine this way
return options.length > 0 && ( element.type == "select-multiple" || ($.browser.msie && !(options[0].attributes['value'].specified) ? options[0].text : options[0].value).length > 0); var val = $(element).val();
return val && val.length > 0;
case 'input': case 'input':
if ( this.checkable(element) ) if ( this.checkable(element) )
return this.getLength(value, element) > 0; return this.getLength(value, element) > 0;