title: AngularJS: How to validate date in US format?
body: <p>I have the following form code that allows input of a date using AngularUI (date is required and should match US date format e.g.: MM/DD/YY):</p>
  
  <pre><code>&lt;form name="form" ng-submit="createShipment()"&gt;
      &lt;!-- Shipment Date must be in MM/DD/YY format: --&gt;  
      &lt;input name="shipmentDate" 
            ng-pattern='/^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$/'
            ui-date="{ dateFormat: 'mm/dd/y' }" required ng-model="shipment.ShipmentDate" type="text"&gt;
      &lt;span ng-show="form.shipmentDate.$error.required"&gt;Date Required!&lt;/span&gt;
      &lt;span ng-show="form.shipmentDate.$error.pattern"&gt;Incorrect Format, should be MM/DD/YY!&lt;/span&gt;
  
      &lt;input class="btn-primary" ng-hide="!form.$valid" type="submit" value="Create"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Validation for <strong>required</strong> field works fine, but date format is not being validated correctly and always shows <strong>'Incorrect Format...'</strong> message. </p>
  
  <p>I tried several different Regular Expressions that worked fine elsewhere, but it is still not working. Also I tried AngularUI validation and it doesn't work either. Thanks in advance!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I figured that validation was conflicting with AngularUI datepicker I used, but datepicker autocorrects date anyway, so if datepicker is not used, than validation works as long as regular expression works, and if datepicker is used, there is not much need for other validation.</p>