Skip to content

Instantly share code, notes, and snippets.

@sTiLL-iLL
Last active December 21, 2015 23:39
Show Gist options
  • Save sTiLL-iLL/6383675 to your computer and use it in GitHub Desktop.
Save sTiLL-iLL/6383675 to your computer and use it in GitHub Desktop.
validate D.O.B.
// Validate date of birth
$("#frm1").submit(function(){
var d = $("#day").val();
var mth = $("#month").val();
var yr = $("#year").val();
// arbitrary number for example
var age = 18;
var dt = new Date();
dt.setFullYear(yr, mth-1, d);
var curdt = new Date();
curdt.setFullYear(curdt.getFullYear() - age);
if ((curdt - dt) < 0){
alert("!!!");
return false;
}
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment