Skip to content

Instantly share code, notes, and snippets.

@aseredenko
Created January 19, 2016 14:23
Show Gist options
  • Save aseredenko/c0605b905c40a3257843 to your computer and use it in GitHub Desktop.
Save aseredenko/c0605b905c40a3257843 to your computer and use it in GitHub Desktop.
Add minimal date which calculated automaticly for input (in Example -75 years from current day)
// Add minimal value for date input
var date = new Date();
var currentYear = date.getFullYear();
var currentMonth = ('0' + (date.getMonth() + 1).toString()).slice(-2);
var currentDay = ('0' + (date.getDate()).toString()).slice(-2);
var minDate = currentYear-75 + "-" + currentMonth + "-" + currentDay;
$(".date-input").prop('min', minDate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment