From bd5527e40cd393f3bed3b0f3061b420f7440c8e9 Mon Sep 17 00:00:00 2001 From: Mireayo Date: Mon, 1 Nov 2021 17:37:52 +0500 Subject: [PATCH] 1-5 --- package-lock.json | 1 + static/index.html | 86 +++++++++++++++++++++++++++++++++++++++++++- static/polite.html | 16 +++++++++ static/styles.css | 22 ++++++++++-- static/validation.js | 26 ++++++++++++++ 5 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 static/polite.html create mode 100644 static/validation.js diff --git a/package-lock.json b/package-lock.json index 6aaf3bc..486f987 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "tables-and-forms", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/static/index.html b/static/index.html index 514b62f..53fdc8f 100644 --- a/static/index.html +++ b/static/index.html @@ -3,14 +3,98 @@ Форма выбора питомца +

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

- +
+
+ Мой питомец мечты +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ Ваши данные + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + +
+
+
\ No newline at end of file diff --git a/static/polite.html b/static/polite.html new file mode 100644 index 0000000..39753d0 --- /dev/null +++ b/static/polite.html @@ -0,0 +1,16 @@ + + + + + + Политика сервиса + + +
+

Политика сервиса "Найди себе друга!"

+
+ +
+
+ + \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index ef86c9a..c11405d 100644 --- a/static/styles.css +++ b/static/styles.css @@ -19,7 +19,7 @@ h1 { margin-top: 0; font-size: 50px; text-align: center; - color: rgba(173,38,164,0.67); + color: #3F51B5; } .error { @@ -28,4 +28,22 @@ h1 { .orders { margin: 20px 0; -} \ No newline at end of file +} + +input[type=text], +input[type=email], +input[type=tel]{ + padding: 10px; + margin: 10px 0; + border: none; + border-radius: 0; + border-bottom: 1px solid darkgray; + width: 50%; +} + +.secret-parent{ + display: flex; + align-items: center; + align-content: center; + justify-content: center; +} diff --git a/static/validation.js b/static/validation.js new file mode 100644 index 0000000..4cb8e28 --- /dev/null +++ b/static/validation.js @@ -0,0 +1,26 @@ +let form = document.querySelector(".form"); +let phone = document.querySelector("input[name='phone']"); +let email = document.querySelector("input[name='email']"); + +function isPhoneValid() { + let re = /^\d[\d\(\)\ -]{4,14}\d$/; + return phone.value.match(re); +} + +function isMailValid() { + let re = /\+7 \(\d{3}\) \d{3}-\d{2}-\d{2}/; + return email.value.match(re); +} + +form.addEventListener("submit", (event) => { + let validMail = isMailValid() + let validPhone = isPhoneValid(); + if(!validMail) { + alert("Неправильный e-mail"); + event.preventDefault(); + } + if(!validPhone) { + alert("Неправильный номер телефона"); + event.preventDefault(); + } +}); \ No newline at end of file