Last active
December 21, 2015 23:39
-
-
Save sTiLL-iLL/6383675 to your computer and use it in GitHub Desktop.
validate D.O.B.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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