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.

for reference

function jsfunctionvalidate() { if(document.getelementbyid('<%=ddlview.clientid%>').selectedindex == 0) { alert("please select ddl"); return false; } return true; } 

just call method in dropdown..


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -