-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton3.html
More file actions
146 lines (129 loc) · 4.85 KB
/
Copy pathbutton3.html
File metadata and controls
146 lines (129 loc) · 4.85 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Реєстрація</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 70px;
border: 1px solid #6a85f1;
border-radius: 100px;
background-color: #d1eff4;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
font-weight: bold;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
}
select, input[type="text"] {
margin-top: 5px;
}
input[type="submit"] {
background-color: #007bff;
color: #fff;
padding: 20px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
margin: 0 auto;
display: block;
width: 170px;
height: 60px;
font-size: 18px;
}
.phone-input-container {
display: flex;
}
.country-code {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #f5f5f5;
}
.phone-number {
flex: 2;
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
}
.my-button {
width: 80px;
height: 50px;
}
</style>
</head>
<body background="1111.jpg">
<a href="button.html" ><button class="my-button">На головну</button></a>
<div class="container">
<center><h1>Реєстрація</h1></center>
<form action="button.html" method="post">
<div class="form-group">
<label for="username">Ім'я та Прізвище:</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="phoneNumber">Номер телефону:</label>
<div class="phone-input-container">
<select class="country-code" id="countryCode" name="countryCode">
<option value="+48">+48</option>
<option value="+380">+380</option>
<option value="+050">+050</option>
<!-- Додайте інші коди країн за потреби -->
</select>
<input type="text" class="phone-number" id="phoneNumber" name="phoneNumber" required>
</div>
</div>
<div >
<a class="form-group" width=170px;
height=60px;><button>Зареєструватися</button></a>
</div>
</form>
</div>
<script>
// Отримуємо елементи DOM
const countryCodeSelect = document.getElementById("countryCode");
const phoneNumberInput = document.getElementById("phoneNumber");
// Додаємо події "change" до вибору коду країни
countryCodeSelect.addEventListener("change", updatePhoneNumber);
phoneNumberInput.addEventListener("input", handlePhoneNumberInput);
// Функція для оновлення вибраного коду країни в полі номера телефону
function updatePhoneNumber() {
const selectedCountryCode = countryCodeSelect.value;
const phoneNumber = phoneNumberInput.value;
phoneNumberInput.value = selectedCountryCode + phoneNumber;
}
// Функція для обробки введення номера телефону
function handlePhoneNumberInput() {
const phoneNumber = phoneNumberInput.value;
const countryCodeOptions = countryCodeSelect.options;
}
// Перевіряємо, чи містить введений номер один із кодів країн
for (let i = 0; i < countryCodeOptions.length; i++) {
const countryCode = countryCodeOptions[i].value;
if (phoneNumber.startsWith(countryCode)) {
countryCodeSelect.value = countryCode;
break;
}
}
function handleUsernameInput() {
const username = usernameInput.value;
userNameDisplay.textContent = `Ім'я та Прізвище: ${username}`;
}
</script>
</body>
</html>