Skip to content

Instantly share code, notes, and snippets.

@khsuzan
Created December 14, 2022 05:48
Show Gist options
  • Save khsuzan/a19c392c299cc081bb68084d1db75ffe to your computer and use it in GitHub Desktop.
Save khsuzan/a19c392c299cc081bb68084d1db75ffe to your computer and use it in GitHub Desktop.
const dateInput = document.getElementById('date');
dateInput.addEventListener('change', e => {
const inputDateString = e.target.value;
const today = new Date();
const minDate = new Date(inputDateString);
minDate.setDate(minDate.getDate() + 1);
if(today<minDate){
// this block will run only when user input date at least greater 1 day
// comparison to today date
console.log(inputDateString)
console.log("I go next")
}else{
// if date is less then one day greater this block
// will run
console.log("Date error")
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment