You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
712 B
26 lines
712 B
document.addEventListener("DOMContentLoaded", function() {
|
|
var inputDate = document.querySelector("form input[name=\"fictionalDate\"]")
|
|
var pError = document.querySelector("form p.red")
|
|
|
|
if (inputDate.value != "") {
|
|
inputDate.value = new Date(inputDate.value).toDateString().substring(4)
|
|
}
|
|
|
|
document.querySelector("form").onsubmit = function(ev) {
|
|
console.log(inputDate.value)
|
|
|
|
var date = new Date(inputDate.value + " UTC")
|
|
if (Number.isNaN(date.getTime())) {
|
|
date = new Date(inputDate.value)
|
|
|
|
if (Number.isNaN(date.getTime())) {
|
|
pError.innerHTML = "Invalid date"
|
|
|
|
return false
|
|
}
|
|
}
|
|
|
|
inputDate.value = date.toISOString()
|
|
return true
|
|
}
|
|
})
|