angularjs - add remove required validation in angular dynamically in angular js -
i have form shown below, have kept 1 field here simplicity. in form have many other fields including country dropdown. if country selected a,b or c want remove required validation using addressrequired
gets true/false value on alter of country.
i removing required using .removeattr()
, remove html.
but ng-disabled="myabcform.$invalid"
stills shows invalid.
<form name="myabcform" ng-submit="submitform(myabcform.$valid)" novalidate class="myabcform"> <div class="element-box fltlt"> <label>address </label><sup ng-show="addressrequired">*</sup> <input type="text" value="" ng-model="details.address" required=""> <span ng-show="!details.address && addressrequired" class="error-msg field-validation-error">address required.</span> </div> <div id="clearfix"> <input type="submit" value="update" class="btn fltlt btnbg" ng-disabled="myabcform.$invalid" /> </div> </form>
any suggestions ?
use ngrequired
instead, like:
ng-required="checkcountry()"
http://jsfiddle.net/coma/0jz49knd/1/
angularjs
No comments:
Post a Comment