-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyscript.js
27 lines (23 loc) · 1.1 KB
/
myscript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var userMonth = document.getElementById("user-month");
var userDay = document.getElementById("user-day");
var userYear = document.getElementById("user-year");
var submitButton = document.getElementById("submit-date");
submitButton.addEventListener("click", function(evt) {
var message = document.getElementById('message');
var parsedMonth = (parseInt(userMonth.value)-1);
var parsedDay = parseInt(userDay.value);
var parsedYear = parseInt(userYear.value);
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var dateIs = new Date(parsedYear, parsedMonth, parsedDay);
var weekdayIs = weekday[dateIs.getDay()];
var monthIs = months[parsedMonth];
if (weekdayIs === undefined || monthIs === undefined) {
message.innerText= "";
setTimeout(function() {
message.innerText="Please enter a valid date!";}, 500)
}
else{
message.innerText = weekdayIs +" , "+ monthIs + " " + parsedDay + " , " +parsedYear;
}
})