Disable validation for disabled Angular control forms

I have a button that should be disabled until the form is valid. However, depending on the situation, some form fields are also disabled. My problem is that I need the user to fill out optional form fields, but angular doesn't seem to check for disabled fields.

<button ng-click="form.checkVerify(); appCtrl.pageLoad('spec')" ng-disabled="checkVerifyForm.$invalid" class="btn btn-lg btn-success pull-right">Complete</button> <form name="checkVerifyForm"> <div class="col-md-6"> <fieldset ng-disabled="!form.dataStore.reqMake"> <label for="makeRec">Maker Recourse</label> <div class="form-group"> <label class="radio-inline"> <input ng-change="form.justify()" ng-model="form.verify.mRec" type="radio" name="makeRec" id="makeRecYes" value="1" /> Yes </label> <label class="radio-inline"> <input ng-change="form.justify()" ng-model="form.verify.mRec" type="radio" name="makeRec" id="makeRecNo" value="0" /> No </label> <span id="helpBlock" class="help-block">Is there adequete recourse...</span> </div> 

Now I have seen some rather intense directives that perform the task, but is there anything simple that can be done in the controller to overcome this specific situation?

+5
source share
1 answer

You can use for example. ng-required to achieve this.

 <input ng-change="form.justify()" ng-model="form.verify.mRec" type="radio" name="makeRec" id="makeRecYes" value="1" ng-required="form.dataStore.reqMake" /> Yes 

AngularJS Connectivity Documentation

+3
source

Source: https://habr.com/ru/post/1212255/


All Articles