0

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>

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I want to put a check that if 'end date' is less than the 'start date' then submit button should be disabled, which is not happening in your demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.