jquery validator not working for require from group? -


html

<form id="myform" method="post" action="/" >     <input type="text"   name="number0" class="form-control">     <input type="text"  name="amount0"  class="form-control send">     <input type="text"  name="operator0" class="form-control ">     <select id="bundle0" name="bundle" class="bundle send" >         <option>a</option>         <option>b</option>     </select>     <input type="text"   name="number1" class="form-control">     <input type="text"  name="amount1"  class="form-control send">     <input type="text"  name="operator1" class="form-control ">     <select id="bundle" name="bundle2" class="bundle send" >         <option>a</option>         <option>b</option>     </select>     ........//upto n numbers     <input type="submit" value="submit" /> </form> 

jquery validator

$("#myform").validate({     rules : {         amount0: {             require_from_group: [1, ".send"]         },         bundle0: {             require_from_group: [1, ".send"]         },         operator0:"required"     } }); 

issues:

1) require group not working select box. want either selectbox bundle or amount filled

2) how validation fileds operator0,operator1 etc..

1) require group not working select box.

you don't have select box declared in rules object. rules declared based on name, not id.

additionally, validate select element plugin, first option must contain value='' attribute. notice value empty string. otherwise, default value content between <option></option> tags. since value not empty, rule satisfied before making selection.

<select id="bundle0" name="bundle" class="bundle send">     <option value=''>please choose</option>     <option>a</option> <!-- // value defaults "a" //-->     .... 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -