You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/4-forms-submit/1-modal-dialog/task.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,32 @@ importance: 5
2
2
3
3
---
4
4
5
-
# Modal form
5
+
# Модальное диалоговое окно с формой
6
6
7
-
Create a function `showPrompt(html, callback)` that shows a form with the message `html`, an input field and buttons `OK/CANCEL`.
7
+
Создайте функцию `showPrompt(html, callback)`, которая выводит форму с сообщением (`html`), полем ввода и кнопками `OK/ОТМЕНА`.
8
8
9
-
-A user should type something into a text field and press `key:Enter`or the OK button, then `callback(value)`is called with the value they entered.
10
-
-Otherwise if the user presses `key:Esc`or CANCEL, then `callback(null)` is called.
9
+
-Пользователь должен ввести что-то в текстовое поле и нажать `key:Enter`или кнопку "OK", после чего должна вызываться функция `callback(value)`со значением поля.
10
+
-Если пользователь нажимает `key:Esc`или кнопку "ОТМЕНА", тогда вызывается `callback(null)`.
11
11
12
-
In both cases that ends the input process and removes the form.
12
+
В обоих случаях нужно завершить процесс ввода и закрыть диалоговое окно с формой.
13
13
14
-
Requirements:
14
+
Требования:
15
15
16
-
-The form should be in the center of the window.
17
-
-The form is *modal*. In other words, no interaction with the rest of the page is possible until the user closes it.
18
-
-When the form is shown, the focus should be inside the `<input>` for the user.
19
-
-Keys`key:Tab`/`key:Shift+Tab`should shift the focus between form fields, don't allow it to leave for other page elements.
16
+
-Форма должна быть в центре окна.
17
+
-Форма является *модальным окном*, это значит, что никакое взаимодействие с остальной частью страницы невозможно, пока пользователь не закроет его.
18
+
-При показе формы, фокус должен находиться сразу внутри `<input>`.
19
+
-Клавиши`key:Tab`/`key:Shift+Tab`должны переключать фокус между полями формы, не позволяя ему переходить к другим элементам страницы.
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/4-forms-submit/article.md
+29-27Lines changed: 29 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,55 +1,57 @@
1
-
# Form submission: event and method submit
1
+
# Отправка формы: событие и метод submit
2
2
3
-
The `submit` event triggers when the form is submitted, it is usually used to validate the form before sending it to the server or to abort the submission and process it in JavaScript.
3
+
При отправке формы срабатывает событие `submit`, оно обычно используется для проверки (валидации) формы перед её отправкой на сервер или для предотвращения отправки и обработки её с помощью JavaScript.
4
4
5
-
The method `form.submit()`allows to initiate form sending from JavaScript. We can use it to dynamically create and send our own forms to server.
5
+
Метод `form.submit()`позволяет инициировать отправку формы из JavaScript. Мы можем использовать его для динамического создания и отправки наших собственных форм на сервер.
6
6
7
-
Let's see more details of them.
7
+
Давайте посмотрим на них подробнее.
8
8
9
-
## Event: submit
9
+
## Событие: submit
10
10
11
-
There are two main ways to submit a form:
11
+
Есть два основных способа отправить форму:
12
12
13
-
1.The first -- to click`<input type="submit">`or`<input type="image">`.
14
-
2.The second -- press`key:Enter` on an input field.
2.Второй -- нажать`key:Enter`, находясь на каком-нибудь поле.
15
15
16
-
Both actions lead to`submit`event on the form. The handler can check the data, and if there are errors, show them and call`event.preventDefault()`, then the form won't be sent to the server.
16
+
Оба действия сгенерируют событие`submit`на форме. Обработчик может проверить данные, и если есть ошибки, показать их и вызвать`event.preventDefault()`, тогда форма не будет отправлена на сервер.
17
17
18
-
In the form below:
19
-
1. Go into the text field and press `key:Enter`.
20
-
2. Click `<input type="submit">`.
18
+
В примере ниже:
21
19
22
-
Both actions show `alert` and the form is not sent anywhere due to `return false`:
20
+
1. Перейдите в текстовое поле и нажмите `key:Enter`.
21
+
2. Нажмите `<input type="submit">`.
22
+
23
+
Оба действия показывают `alert` и форма не отправится благодаря `return false`:
23
24
24
25
```html autorun height=60 no-beautify
25
26
<formonsubmit="alert('submit!');return false">
26
-
First: Enter in the input field <inputtype="text"value="text"><br>
To submit a form to the server manually, we can call `form.submit()`.
50
+
Чтобы отправить форму на сервер вручную, мы можем вызвать метод `form.submit()`.
49
51
50
-
Then the `submit` event is not generated. It is assumed that if the programmer calls `form.submit()`, then the script already did all related processing.
52
+
При этом событие `submit` не генерируется. Предполагается, что если программист вызывает метод `form.submit()`, то он уже выполнил всю соответствующую обработку.
51
53
52
-
Sometimes that's used to manually create and send a form, like this:
54
+
Иногда это используют для генерации формы и отправки её вручную, например так:
53
55
54
56
```js run
55
57
let form = document.createElement('form');
@@ -58,7 +60,7 @@ form.method = 'GET';
58
60
59
61
form.innerHTML = '<input name="q" value="test">';
60
62
61
-
// the form must be in the document to submit it
63
+
// перед отправкой формы, её нужно вставить в документ
0 commit comments