javascript - jQuery select option validation -


in question page, have list of questions in type of text, select, checkbox, radio, date , upload. except select, options can written in input. doing validation input , select now. stuck in select validation.

here validation script:

$(document).ready(function() {     //validate     $('form.confirm').on('click', function(e) {         e.preventdefault();         // adding rules inputs          $('input').each(function() {             $(this).rules("add", {                 required: true             });         });              $('select').each(function() {             console.log('1111111');             $(this).rules("add", {                 selectcheck: true             });         });             jquery.validator.addmethod('selectcheck', function (value) {             return (value != '-1');         }, "required");     })               }); 

here php select:

<select name='awid-<?php echo $this->question[$i]->id; ?>[]' id='qta_<?php echo $this->question[$i]->id; ?>'  class="ans form-control awslt" required     <?php      //check fllowing answer     echo "clas='".$ans->clauseida."'";     if ($this->question[$i]->trignext) {         echo "onchange='trignext(\"select\",this)'";     } else {         echo "clas='".$ans->clauseida."' onchange='assign(\"select\",this)' ";     }     ?>     >                                                <option value="-1" triger='["0"]' clas='["0"]' id="-1"> please select answer </option>           <?php     ($m = 0; $m < sizeof($this->question[$i]->answers); $m++) {         ?>         <option value="<?php echo $this->question[$i]->answers[$m]->id; ?>" triger= '<?php echo $this->question[$i]->answers[$m]->nextida; ?>'> <?php echo $this->question[$i]->answers[$m]->answertxt ?></option>           <?php     }     ?> </select> 

the issue select validation not work. can me?


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 -