jQuery validation wont fire for dropdown/select lists -
yes might duplicate of million other questions it, me still doesnt work. according jquery validation documentation, having first default item empty value (value=""), , class "required" enough. refuses work correctly. have set correctly, , works fine on checkboxes, radiobuttons, text inputs no problem @ all, select lists? nope.
here simple example:
<select class="required" id="daydropdown" data-bind="'value': studentbasedata.day">     <option value="">dag</option> </select> <select class="required" id="monthdropdown" data-bind="'value': studentbasedata.month">     <option value="">måned</option> </select> <select class="required" id="yeardropdown" data-bind="'value': studentbasedata.year">     <option value="">År</option> </select> three dropdownlists, required. right here, odd thing first select validates. other 2 ignored. further down page have 2 more select lists refuses kind of validation.
here initiate validation plugin:
$(function(){     $.metadata.settype("attr", "validate");     $("#studentsform").validate({         ignore: ""     }); }); and force trigger validation when form submitted:
$('#updateprofilebutton').click(function subscribe() {     if($("#studentsform").valid()=== true){ //force trigger validation         // stuff     } else { // if jquery validation fails         // todo     } }); and said, works select lists.
if matters, select lists automatically populated 2 javascript functions (filling out dates etc.), initial default value set have shown above. strange thing works first select box, , thats it.
i have searched , searched , have never found same problem.
ps: "data-bind" knockout.js.
add name attribute dropdowns. should fix problem see first dropdown being shown invalid.
Comments
Post a Comment