title: Age validation using dd/mm/yyyy
body: <p>I am trying to validate a form I have for age validating using javascript but it doesn't seem to be working.. not sure why.</p>
  
  <p>Basically the date of birth is entered : <code>dd/mm/yyyy</code> and I need to make sure that in order to submit the form the age of the person is between <code>15 - 80</code>.. I have tried validating this way but doesn't seem to work.</p>
  
  <p>Html </p>
  
  <pre><code>&lt;label&gt;
      Date of birth:
      &lt;input type="text" name="birth date" id="DOB" 
             placeholder="dd/mm/yyyy" maxlength="10" pattern="\d{1,2}\/\d{1,2}\/\d{4}" 
             required="required"/&gt;
  &lt;/label&gt;
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>var birthDate = document.getElementById("DOB").value;
  
  if (2019 - birthDate &lt; 15 || 2019 - birthDate &gt; 80) {
    errMsg =errMsg + "your age must be between 15 and 80\n";
    result = false;
  }
  
  if (errMsg !== "") {
    alert(errMsg);
  }
  
  return result;
  </code></pre>