Skip to content

Ланских Михаил #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 79 additions & 3 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,89 @@
<meta charset="UTF-8">
<title>Форма выбора питомца</title>
<link rel="stylesheet" href="styles.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<main>
<body class="bg-info">
<main class="border border-5">
<h1>Найди себе друга!</h1>

<!--Форму размещай тут-->
<div class="wrapper">
<form method="post" action="/pets/orders">
<div class="petType">
<label for="petType">Выберите животное</label>
<br>
<select name="petType">
<option value="cat">Кошка</option>
<option value="dog">Собака</option>
<option value="tiger">Тигр</option>
</select>
</div>

<div class="gender">
<label for="gender">Выберите пол</label>
<div class="choose">
<div class="genders">
<input type="radio" name="gender" value="boy" id="boy">
<label for="boy">Самец</label>
<br>
<input type="radio" name="gender" value="girl" id="girl">
<label for="girl">Самка</label>
<br>
<input type="radio" name="gender" value="none" id="none" checked>
<label for="none">Не указано*</label>
</div>
<div class="description text-black-50">*если пол не указан (none), то в дальнейшем он будет выбран случайно</div>
</div>
</div>

<div class="eyeColor">
<label for="eyeColor">Выберите цвет глаз</label>
<br>
<input type="color" name="eyeColor" value="#e19a44">
</div>

<div class="tailLength">
<label for="tailLength">Введите длину хвоста (в см)</label>
<br>
<input type="number" name="tailLength" min="7" max="120" value="7">
</div>

<div class="name">
<label for="name">Введите Ваше имя</label>
<br>
<input type="text" name="name" id="name" placeholder="от 3 до 50 символов" required>
</div>

<div class="dateOfBirth">
<label for="dateOfBirth">Выберите дату рождения</label>
<br>
<input type="date" name="dateOfBirth">
</div>

<div class="email">
<label for="email">Введите Ваш email</label>
<br>
<input type="email" name="email" id="email" required>
</div>

<div class="phone">
<label for="phone">Введите Ваш номер телефона</label>
<br>
<input type="tel" name="phone" id="phone" required>
</div>

<div class="rules">
<input type="checkbox" class="form-check-input" name="rules" value="true">
<label for="rules">Согласен с условиями <a href="/">политики конфиденциальности</a></label>
</div>

<div class="buttons">
<input type="submit" class="btn btn-success">
<input type="reset" class="btn btn-warning">
</div>
</form>
</div>
</main>
<script src="validation.js"></script>
</body>
</html>
76 changes: 72 additions & 4 deletions static/styles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
body {
background-color: #F2F2F2;
}

main {
box-sizing: border-box;
width: 100%;
Expand All @@ -28,4 +24,76 @@ h1 {

.orders {
margin: 20px 0;
}

.wrapper {
margin: auto;
width: 500px;
}

form {
display: flex;
flex-direction: column;
align-content: space-around;
margin-top: 30px;
}

form div {
display: flex;
justify-content: space-between;
margin-top: 20px;
}

form .gender {
display: block;
align-items: start;
}

.genders {
display: block;
}

.genders label, .genders input {
margin-bottom: 10px;
}

.description {
width: 200px;
}

.choose {
margin-top: 0;
}

.rules {
align-content: center;
}

.rules input {
margin: auto;
}

table {
border-collapse: collapse;
width: 100%;
background-color: mediumaquamarine;
border: 2px solid yellowgreen;
}

th {
font-weight: bold;
color: rgb(65, 12, 12);
border: 2px solid yellowgreen;
border-radius: 5%;
background-color: rgb(96, 163, 226);
}

tr:nth-child(2n) {
background-color: khaki;
}

td {
text-align: center;
box-sizing: border-box;
border: 1px solid yellowgreen;
}
8 changes: 8 additions & 0 deletions static/validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const name = document.querySelector('#name');
const phone = document.querySelector('#phone');

name.addEventListener('input', () => name.setCustomValidity(name.value.length < 3 ? 'Имя введено некорректно' : ''));

phone.addEventListener('input', () => phone.setCustomValidity(/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/.test(phone.value)
? ''
: 'Номер введен некорректно'));