jquery - Validating two dropdowns in a single anchor tag click event -
i have validate 2 dropdowns in anchor tag click event.
$(".viewmore").on('click',function(event){ return requiredvalidation($(this).parents('.box01').find(".color")); return requiredvalidation($(this).parents('.box01').find(".size")); }); function requiredvalidation(ddl) { ddl = $(ddl); var isvalid = true; if (jquery.trim(ddl.val()) == 'vÆlg' ) { isvalid = false; ddl.addclass("error"); } else { ddl.removeclass("error"); } return isvalid; }
but first 1 validating here.can 1 give clue?
use
$(".viewmore").on('click',function(event) { var valid1 = requiredvalidation($(this).parents('.box01').find(".color")); var valid2 = requiredvalidation($(this).parents('.box01').find(".size")); return valid1 && valid2; });
you returning after first select validated, need validate both input fields combine result
Comments
Post a Comment