-
-
Save tobijibu/4d2a7e44cf7cd5ff7d013494bd241bb8 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="https://npmcdn.com/flatpickr/dist/flatpickr.min.css" /> | |
<link rel="stylesheet" href="https://npmcdn.com/flatpickr/dist/themes/material_green.css" /> | |
<script src="https://npmcdn.com/flatpickr/dist/flatpickr.min.js"></script> | |
</head> | |
<body> | |
<form> | |
<input id="calendar" type="text" value=""> | |
</form> | |
<script> | |
//flatpickr | |
let calendar = flatpickr('#calendar', {allowInput: true}); | |
let obj = document.getElementById('calendar'); | |
obj.addEventListener('keydown', function(e) { | |
if (e.keyCode == 13 || e.keyCode == 9) { | |
calendar.setDate(this.value); | |
calendar.close(); | |
} | |
}, false); | |
//submit無効化 | |
document.forms[0].onsubmit = function(){ | |
return false; | |
}; | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment