I am working on Angualrjs.below is my code
<form name="myForm" ng-submit="OnClickSubmit())">
<div ng-repeat="ReadItem in SelectedItem" >
<label class="input">
<input type="text" id="txt_{{ReadItem.No}}" ng-model="ReadItem.Quantity" name="Quantity" required />
<div ng-show="myForm.Quantity.$dirty && myForm.Quantity.$error.required" class="note field-error">Required!</div>
<div ng-show="(myForm.Quantity.$dirty && ((5 < ReadItem.Quantity))" class="note field-error">Qty More.</div>
</label>
</div>
<button >order</button>
</form>
i wanted to perform validation on condition only when i click single button order.button is placed bottom of page.it's not added on every row.
1.my form is valid, i mean all field is not empty.
2.and quantity should not grater than 5. please let me know how to achieve this functionality on multiple row item.
if any condition fail then OnClickSubmit() should not fired.
答案 0 :(得分:0)
如果我的问题正确,ng-disabled
和$invalid
将是您最好的朋友:
<button ng-disabled="myForm.$invalid" >Submit</button>
这将禁用button
,直到所有必填字段生效。