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.
Basically the date of birth is entered : dd/mm/yyyy and I need to make sure that in order to submit the form the age of the person is between 15 - 80.. I have tried validating this way but doesn't seem to work.
Html
<label>
    Date of birth:
    <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"/>
</label>
Javascript
var birthDate = document.getElementById("DOB").value;
if (2019 - birthDate < 15 || 2019 - birthDate > 80) {
  errMsg =errMsg + "your age must be between 15 and 80\n";
  result = false;
}
if (errMsg !== "") {
  alert(errMsg);
}
return result;
 
     
     
     
     
    