From 02aa05ddd2920fbb9af19062701f753d8fa673c9 Mon Sep 17 00:00:00 2001 From: UralGuru <71888215+UralGuru@users.noreply.github.com> Date: Tue, 9 Nov 2021 18:08:00 +0500 Subject: [PATCH] all tasks --- static/index.html | 89 +++++++++++++++++++++++++++++++++++++++++++- static/styles.css | 79 ++++++++++++++++++++++++++++++++++++++- static/submitForm.js | 11 ++++++ static/validator.js | 16 ++++++++ 4 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 static/submitForm.js create mode 100644 static/validator.js diff --git a/static/index.html b/static/index.html index 514b62f..e257dd1 100644 --- a/static/index.html +++ b/static/index.html @@ -9,8 +9,95 @@

Найди себе друга!

- +
+
+ Информация о питомце + +
+ + + +
+ + + +
+ + +
+ + +
+ Информация о себе + + +
+ + + +
+ + + +
+ + + +
+ + +
+ + + +
+ + + + \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index ef86c9a..ab78abe 100644 --- a/static/styles.css +++ b/static/styles.css @@ -28,4 +28,81 @@ h1 { .orders { margin: 20px 0; -} \ No newline at end of file +} + + + + + +form { + width: 700px; + margin: 0 auto; + border: 1px solid #6e6b6b; + border-radius: 10px; + padding: 10px; + font-family: "Segoe UI", sans-serif; + background-color: #ecfeff; +} + +fieldset { + padding: 10px; + margin-bottom: 10px; + border: 1px solid #2c3e50; + border-radius: 5px; +} + +fieldset:last-child { + margin-bottom: 0; +} + +fieldset legend { + margin-left: 400px; + color: #2c3e50; +} + +label { + display: block; + margin-bottom: 5px; +} + +input, select { + border-radius: 10px; +} + +input[type="text"], +input[type="color"], +input[type="tel"], +input[type="email"], +input[type="date"], +input[type="number"], +select { + width: 95%; + height: 24px; + margin-bottom: 10px; + margin-top: 10px; + padding: 2px 5px; + box-sizing: content-box; + border: 1px solid #cccccc; +} + +input[type="submit"], +input[type="reset"] { + display: inline-block; + margin: 0 5px; + padding: 6px 15px; + + color: #ffffff; + + background-color: #2d4863; + border: none; +} + +input[type="submit"]:disabled { + opacity: 0.25; +} + +.buttons { + margin-top: 10px; + text-align: right; +} + diff --git a/static/submitForm.js b/static/submitForm.js new file mode 100644 index 0000000..2141d6a --- /dev/null +++ b/static/submitForm.js @@ -0,0 +1,11 @@ +let submit = document.querySelector("input[type=submit]"); +let reset = document.querySelector("input[type=reset]"); +let rules = document.querySelector("input[name=rules]"); + +rules.onchange = function () { + submit.disabled = !rules.checked; +} + +reset.onclick = function () { + submit.disabled = true; +} diff --git a/static/validator.js b/static/validator.js new file mode 100644 index 0000000..c290869 --- /dev/null +++ b/static/validator.js @@ -0,0 +1,16 @@ +let telPhone = document.querySelector(".phone"); +let form = document.querySelector('form'); + +function validatePhone() { + const regex = /\+7 \(\d{3}\) \d{3}-\d{2}-\d{2}/; + return telPhone.value.match(regex); +} + +form.addEventListener("submit", (e) => { + let isValidEmail = validatePhone(); + if(!isValidEmail) { + alert("Данные не валидны"); + telPhone.focus(); + e.preventDefault(); + } +}); \ No newline at end of file