Skip to content

Instantly share code, notes, and snippets.

@yayadrian
Created September 17, 2010 15:25
Show Gist options
  • Save yayadrian/584387 to your computer and use it in GitHub Desktop.
Save yayadrian/584387 to your computer and use it in GitHub Desktop.
$("#date").blur(function() {
var value= $(this).val();
var userDate = new Date(value);
var dateString = Date();
var currDate = new Date(dateString);
var minDate = new Date(dateString);
var maxDate = new Date(dateString);
//var minDate = currDate;
minDate.setFullYear(currDate.getFullYear() - 5);
// var maxDate = currDate;
maxDate.setFullYear(currDate.getFullYear() - 100);
if(userDate > minDate || userDate < maxDate) {
alert(currDate.getFullYear() + " bad date is max: " + maxDate.getFullYear() + " or the min" + minDate.getFullYear());
} else {
alert("its ok");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment