-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (79 loc) · 2.11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Age Validation</title>
<style>
/* updated color palette */
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #F9F1E9;
margin: 0;
}
.container {
width: 300px;
background-color: #fff;
padding: 2rem;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
input[type="number"] {
width: 100%;
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 3px;
font-size: 14px;
}
.message {
color: red;
font-size: 14px;
}
/* updated button style */
button[type="submit"] {
background-color: #F05454;
border: none;
color: #fff;
padding: 0.5rem 1rem;
font-size: 14px;
border-radius: 3px;
cursor: pointer;
}
button[type="submit"]:hover {
background-color: #D94343;
}
</style>
</head>
<body>
<div class="container">
<label for="age">Введите свой возраст:</label>
<input type="number" id="age" name="age" min="1" max="999" oninput="validateAge(this)">
<p class="message" id="message"></p>
<!-- added submit button -->
<button type="submit" onclick="submitAge()">Отправить</button>
</div>
<script>
function validateAge(input) {
const messageElement = document.getElementById("message");
const value = parseInt(input.value);
if (value < 18) {
messageElement.textContent = "Вам еще нет 18 лет";
} else if (value > 150) {
messageElement.textContent = "Вы точно человек?";
} else {
messageElement.textContent = "";
}
}
// added function to handle submit button click
function submitAge() {
const age = document.getElementById("age").value;
alert(`Ваш возраст: ${age}`);
}
</script>
</body>
</html>