-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubmit.html
More file actions
130 lines (118 loc) · 3.34 KB
/
Copy pathsubmit.html
File metadata and controls
130 lines (118 loc) · 3.34 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>User Input Page</title>
<style>
/* CSS styles */
body {
font-family: Arial, sans-serif;
background-color: #f8f8f8;
margin: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 40px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
font-size: 32px;
margin-bottom: 20px;
}
input[type="text"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
transition: border-color 0.3s;
}
input[type="text"]:focus {
outline: none;
border-color: dodgerblue;
}
.btn {
background-color: dodgerblue;
color: #fff;
border: none;
padding: 12px 24px;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #0066cc;
}
.error {
border-color: red;
}
.datetime {
font-size: 20px;
margin-top: 40px;
color: #555;
}
.time {
font-weight: bold;
color: dodgerblue;
font-size: 36px;
margin-bottom: 10px;
}
.date {
text-transform: uppercase;
letter-spacing: 2px;
font-size: 18px;
color: #999;
}
</style>
</head>
<body>
<div class="container">
<h1>Enter your input:</h1>
<form id="myForm">
<input id="userInput" placeholder="Your input here..." type="text">
<button class="btn" type="submit">Submit</button>
</form>
<div class="datetime">
<div class="time" id="currentTime"></div>
<div class="date" id="currentDate"></div>
</div>
</div>
<script>
function submitInput(event) {
event.preventDefault();
const userInput = document.getElementById("userInput");
const u_input = userInput.value;
if (u_input === "") {
userInput.classList.add("error");
userInput.setAttribute("placeholder", "Please enter your input");
} else {
window.location.href = window.location.href + "?input=" + encodeURIComponent(u_input);
}
}
function updateTime() {
const now = new Date();
const time = now.toLocaleTimeString([], {
hour: "numeric",
minute: "2-digit",
hour12: true
});
const date = now.toLocaleDateString([], {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
});
document.getElementById("currentTime").innerHTML = time;
document.getElementById("currentDate").innerHTML = date;
}
setInterval(updateTime, 1000); // call updateTime every second
document.getElementById("myForm").addEventListener("submit", submitInput);
</script>
</body>