title: Angular 7 pattern to validate the Date format DD/MM/YYYY using regx
body: <p>Trying to validate the date format in Angular "DD/MM/YYYY" using regx in pattern</p>
  
  <p><strong>Pattern I used</strong></p>
  
  <pre><code>    public static readonly TAG_DATE_FORMAT_VALUE_REGX : string = '/^(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}$/';
   public static readonly TAG_DATE_FORMAT_VALUE_REGX : string = '^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$';
  
   public static readonly TAG_DATE_FORMAT_VALUE_REGX : string = '  ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$';
  
   public static readonly TAG_DATE_FORMAT_VALUE_REGX : string = '^[0-3]?[0-9]/[0-3]?[0-9]/(?:[0-9]{2})?[0-9]{2}$';
  </code></pre>
  
  <p>And Many others. None of them are working for me.</p>
  
  <p><strong>TS Code</strong></p>
  
  <pre><code>eventStartDateTime: [null, Validators.compose([Validators.required, Validators.pattern(ConstantValues.TAG_DATE_FORMAT_VALUE_REGX)])],
  </code></pre>
  
  <p><strong>HTML code</strong>  </p>
  
  <pre><code>&lt;div *ngIf="(f.eventStartDateTime.invalid &amp;&amp; eventform.submitted) || (f.eventStartDateTime.invalid &amp;&amp; (f.eventStartDateTime.dirty || f.eventStartDateTime.touched))"
                      class="invalid-feedback"&gt;
                      &lt;div *ngIf="f.eventStartDateTime.errors.required"&gt; Please provide a starting date/time for this
                         professional learning event. &lt;/div&gt;
                      &lt;div *ngIf="f.eventStartDateTime.errors.pattern"&gt;Invalid Date Format. Valid format - DD/MM/YYYY
                      &lt;/div&gt;
                    &lt;/div&gt;
  </code></pre>
  
  <p>References </p>
  
  <p><a href="https://stackoverflow.com/questions/5465375/javascript-date-regex-dd-mm-yyyy">Javascript date regex DD/MM/YYYY</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15491894/regex-to-validate-date-format-dd-mm-yyyy">Regex to validate date format dd/mm/yyyy</a></p>
  
  <p><a href="https://www.regextester.com/99555" rel="nofollow noreferrer">https://www.regextester.com/99555</a></p>