javascript - Bootstrap Validator & Image Picker - How to validate form if any one of two available select inputs are chosen? -
i using bootstrap-validator form validation, , imagepicker display selects. works great, have come across instance can't solve on own. have form 2 inputs , need form validate if of 2 inputs selected. couldn't find example on bootstrap-validator or imagepicker options
ideally i'd accomplish bootstrap-validator or imagepicker plugin. if not i'll if statement toggle required property.
here form, appreciated. thanks
html
<form role="form"> <h4>select list #1</h4> <div class="form-group"> <label class="hide" for="select-list-1">select list #1</label> <select id="select-list-1" multiple="multiple" class="image-picker form-control" required> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> </div> <h4>select list #2</h4> <div class="form-group"> <label class="hide" for="select-list-2">select list #2</label> <select id="select-list-2" multiple="multiple" class="image-picker form-control" required> <option>option 1</option> <option>option 2</option> <option>option 3</option> </select> </div> <button type="submit" class="btn btn-default action-btn">submit</button> </form>
so decided best way not use bootstrap-validator on form. used clicked callback function in imagepicker determine if of images selected. made button disabled default , toggled depending if images selected or not.
//image picker $("form select").imagepicker({ show_label: true, clicked: function(){ if($('form .thumbnails li div').hasclass('selected')){ // $("form button").removeclass('disabled'); } else { // else $("form button:not('.disabled')").addclass('disabled'); } } });
Comments
Post a Comment