-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
160 lines (129 loc) · 3.15 KB
/
index.html
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
function ch(event) {
var n = (event.which) ? event.which : event.keyCode;
if (n >= 48 && n <= 57) {
return true;
} else {
return false;
}
}
function date_to_day() {
/*Geting Date*/
var day = document.getElementById("day").value;
var month = document.getElementById("month").value;
var year = document.getElementById("year").value;
day = eval(day);
month = eval(month);
year = eval(year);
var m_d = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (year % 4 == 0) {
m_d[2] = 29;
}
if (year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= m_d[month]) {
document.getElementById("date_allert").innerHTML = "";
document.getElementById("day_name").value = "";
month -= 1;
var dat = new Date();
dat.setFullYear(year, month, day);
var dayy = dat.getDay();
document.getElementById("day_name").value = dayy;
switch (dayy) {
case 0:
document.getElementById("day_name").value = "Sunday";
break;
case 1:
document.getElementById("day_name").value = "Monday";
break;
case 2:
document.getElementById("day_name").value = "Tuesday";
break;
case 3:
document.getElementById("day_name").value = "Wednesday";
break;
case 4:
document.getElementById("day_name").value = "Thursday";
break;
case 5:
document.getElementById("day_name").value = "Friday";
break;
case 6:
document.getElementById("day_name").value = "Saturday";
break;
}
} else {
document.getElementById("day_name").value = "";
document.getElementById("date_allert").innerHTML = "<br>" + "<font>*</font>" + "<font>Invalid Date</font>";
}
}
</script>
<style type="text/css">
tt {
font-size: 25px;
}
#div3 {
height: 30px;
width: 200px;
margin-top: 15px;
}
#div1 {
height: 230px;
width: 250px;
border: 5px solid black;
margin-left: auto;
margin-right: auto;
margin-top: 50px;
background-color: #D1CDD5;
border-radius: 10px;
}
#div2 {
margin-left: auto;
margin-right: auto;
width: 200px;
}
#day,
#month {
width: 48px;
}
#year {
width: 94px;
}
#bt {
width: 200px;
}
#day_name {
width: 200px;
}
#day_name,
#bt,
#year,
#day,
#month {
border: 5px solid #C79EFA;
border-radius: 10px;
text-align: center;
margin-top: 12px;
height: 36px;
}
font {
font-size: 12px;
color: red;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2">
<div id="div3"> <tt>Date : </tt> </div>
<input type="text" id="day" placeholder="DD" onkeypress="return ch(event)" maxlength="2">
<input type="text" id="month" placeholder="MM" onkeypress="return ch(event)" maxlength="2">
<input type="text" id="year" placeholder="YYYY" onkeypress="return ch(event)" maxlength="4">
<span id="date_allert"></span><br>
<input type="button" onclick="date_to_day()" id="bt" value="Date To Day"> <br>
<input type="text" id="day_name" readonly>
</div>
</div>
</body>
</html>