I have a form as shown below, I have kept only 1 field here for simplicity. In my form I have many other fields including a country dropdown. If country selected is A,B or CI want to remove the required validation which I do using a addressRequired
which gets a true/false value on change of country.
I am removing the required using .removeAttr()
and it does get remove from the html.
But the 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 is required.</span>
</div>
<div id="clearfix">
<input type="submit" value="Update" class="btn fltlt btnBG" ng-disabled="myAbcForm.$invalid" />
</div>
</form>
Any suggestions ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.