how to do conditional validation in angularjs and ngmessages? -


in form got dropdown yes / no option , when user selects yes additional input box displayed , allows user enter value input box.

how can validate input box using angularjs ngmessages if visible or value in dropdown 'yes'?

html code

                                <div class="col-xs-8">                                     <select ng-model="useravailable">                                         <option value="no">no</option>                                         <option value="yes">yes</option>                                     </select>                                     <input ng-show="useravailable == 'yes'" placeholder="if yes , add name?" type="text" class="form-control" />                                 </div> 

thanks in advance.

try using ng-if instead of ng-show. ng-show removes dom validation doesn't execute on it. ng-show hides it.

<input ng-if="useravailable == 'yes'" placeholder="if yes , add name?" type="text" class="form-control" /> 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -