v6 — возраст считается автоматически по дате рождения
This commit is contained in:
parent
4aee60f329
commit
39cd446b1a
15
index.html
15
index.html
@ -166,8 +166,8 @@ input[type=file]{display:none}
|
||||
<option>Футбол</option>
|
||||
<option>Хоккей на траве</option>
|
||||
</select>>
|
||||
<input type="number" id="regAge" placeholder="Возраст" min="5" max="100">
|
||||
<input type="date" id="regBirth" placeholder="Дата рождения">
|
||||
<input type="number" id="regAge" placeholder="Возраст (авто)" min="5" max="100" readonly style="background:var(--gray-100)">
|
||||
<input type="date" id="regBirth" placeholder="Дата рождения" onchange="calcAge()">
|
||||
</div>
|
||||
<input type="text" id="regClub" placeholder="Клуб / спортивная школа">
|
||||
<div class="grid2">
|
||||
@ -395,6 +395,17 @@ function registerProfile() {
|
||||
loginProfile(profile.id);
|
||||
}
|
||||
|
||||
function calcAge() {
|
||||
const b = document.getElementById('regBirth').value;
|
||||
if (!b) return;
|
||||
const birth = new Date(b);
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birth.getFullYear();
|
||||
const m = today.getMonth() - birth.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
|
||||
document.getElementById('regAge').value = age;
|
||||
}
|
||||
|
||||
function previewRegPhoto() {
|
||||
const f = document.getElementById('regPhoto').files[0];
|
||||
if (!f) return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user