Date validation in AngularJS
<p>I cannot allow future date in my form built in angularjs</p>

<p>Here is my HTML:</p>

<pre><code>&lt;div ngCloak ng-app="laurelMoney" ng-controller="myCtrl"&gt;
  &lt;form name="userForm"&gt;
    &lt;div class="form-group"&gt;
      &lt;input type='date' id="trandate" class="form-control" ng-model="trandate" required ng-class="{ 'has-error' : userForm.trandate.$error }" /&gt;
      &lt;p ng-show="userForm.trandate.$error" class="help-block"&gt;Transaction can't be in future&lt;/p&gt;
    &lt;/div&gt;

    &lt;a href="#" class="btn btn-primary btn-sm btn-block" ng-click="submitForm()" type="submit"&gt;Add Transaction&lt;/a&gt;
  &lt;/form&gt;
</code></pre>

<p>And my javascript isÑ</p>

<pre><code>angular.module('laurelMoney', [])
  .controller('myCtrl', function($scope) {
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth() + 1;
    var yyyy = today.getFullYear();
    if (dd &lt; 10) {
      dd = '0' + dd
    }
    if (mm &lt; 10) {
      mm = '0' + mm
    }
    today = yyyy + '-' + mm + '-' + dd;
    document.getElementById("trandate").setAttribute("max", today);
    $scope.submitForm = function() {

      if ($scope.userForm.$valid) {
        alert('our form is amazing');
      } else {
        console.log("Error");
      }

    };
  });
</code></pre>

<p>This is working fine when the calendar pops up. Future dates are all disabled. but i am able to manually change it to a future date in the date input box. </p>

<p>System is allowing submit for future dates also. How to go about this??</p>

<p><a href="http://plnkr.co/edit/0KLSuWPdQf1LEHmx6iRh" rel="nofollow"><strong>Plunker</strong></a></p>

<p>Thanks.</p>