validate select field depending on id jquery

ArreteLIBgera

New Member
I have a html like\[code\]<div class='form-field-box even' id="one_field_box"> <div class='form-display-as-box' id="one_display_as_box"> one<span class='required'>*</span> : </div> <select id='one' name='one' data-placeholder="Select one" class="chzn-select" style="width:300px;" tabindex="4"> <option value='http://stackoverflow.com/questions/15510501/0'></option> <option value='http://stackoverflow.com/questions/15510501/Corto' selected='selected' >Corto</option> <option value='http://stackoverflow.com/questions/15510501/Largo' >Largo</option> </select> <div class="form-error"></div> <div class='clear'></div> </div>\[/code\]And I have a script:\[code\]function validate(id, error) { var obj = $('#' + id); if(obj.val() == '0' || obj.val() == ''){ obj.parent().parent().find('.form-error').html(error); return true; }return false;}\[/code\]I call this function:\[code\]validate('one', "error in field one.");\[/code\]I am not getting correct navigation, could you please help me correct validate() function ?
 
Back
Top