javascript - How to validate dropdown list using validator in js -
i trying validate drop down in js. here script code
$.validator.addmethod( 'drop_down_validation', function (value, element) { alert ("my_fun") var val = $('#creative_offer_type').val(); alert (val); if (value.length==0 && val=="") { return false; } else return true; }, $.format("must select atleast 1 value") ); var form_rules = { 'creative[offer_type]' : { required: true, drop_down_validation: true }, }; var form_messages = { 'creative_offer_type' : { required: 'you must specify offer type'}, };
is correct? tried out this, doesn't show response in ui.
function jsfunctionvalidate() { if(document.getelementbyid('<%=ddlview.clientid%>').selectedindex == 0) { alert("please select ddl"); return false; } return true; }
just call method in dropdown..
Comments
Post a Comment