Last active
April 4, 2019 23:35
-
-
Save yuizho/55c4d6fe52a21cdb739ac4938e63ac7f to your computer and use it in GitHub Desktop.
input-date snippet
This file contains 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
<input id="date-form" type="date" min="2019-04-01" max="2030-03-31"> | |
<script> | |
(function() { | |
var dateForm = document.querySelector('#date-form'); | |
var today = new Date(); | |
var month = ('0' + (today.getMonth() + 1)).slice(-2); | |
var day = ('0' + today.getDate()).slice(-2); | |
// set today as default value | |
dateForm.value = `${today.getFullYear()}-${month}-${day}` | |
}()) | |
</script>u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment