Reputation: 21
I am enabling and disabling submit button in my form based upon $invalid. i have two dates in my form start date and end date. how/Where should i set $invalid to true or false
code snippet:
<p ng-show="formName.endTime <= formName.startTime " class="help-block">
<img src="img/warn.png">End Date should always be greater than Start Date.
</p>
Upvotes: 0
Views: 832
Reputation: 1587
Can you please see demo here http://plnkr.co/edit/msVjtQsqUFMuRliIMwVC?p=preview In this case you have to do check formName.$invalid like
<form name="myForm" ng-controller="FormController" class="my-form">
from: <input name='fromDate' type='date' ng-model="fromDate" required>
to: <input type="date" name="toDate" ng-model="toDate" required>
<input type="submit" ng-disabled="myForm.$invalid" value="Upload" />
</form>
Hope this will help you
Upvotes: 1