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
+13-13Lines changed: 13 additions & 13 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
+
# Formuário modal
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
+
Crie uma função`showPrompt(html, callback)`onde mostra um formulário com uma mensagem`html`, um campo de entrada e botões`OK/CANCEL`.
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
+
-Um usuário deve esprever algo dentro do campo de texto e pressionar `key:Enter`ou o botão de OK button, então é chamado o `callback(value)`com o valor que foi inserido.
10
+
-Porém, se o usuário pressionar`key:Esc`ou CANCEL, então`callback(null)`é chamado.
11
11
12
-
In both cases that ends the input process and removes the form.
12
+
Em ambos os casos, isso encerra o processo de entrada e remove o formulário.
13
13
14
-
Requirements:
14
+
Requisitos:
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
+
-O formulário deve estar no centro da janela.
17
+
-O formulário é um *modal*. Em outras palavras, não será possível interagir com o restante da página até que o usuário a feche.
18
+
-Quando o formulário for exibido, o foco do usuário deverá estar dentro do campo `<input>`.
19
+
-As teclas `key:Tab`/`key:Shift+Tab`devem alternar o foco entre os campos do formulário, não permitindo que o foco saia para outros elementos da página.
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/4-forms-submit/article.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,39 +1,39 @@
1
-
# Forms: event and method submit
1
+
# Formulários: evento e método 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
+
O evento `submit`é disparado quando o formulário é submetido. Geralmente, é usado para validar o formulário antes de enviá-lo ao servidor ou para abortar o envio e processá-lo no 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
+
O método`form.submit()`permite iniciar o envio de formulários a partir do JavaScript. Podemos usá-lo para criar e enviar dinamicamente nossos próprios formulários para o servidor.
6
6
7
-
Let's see more details of them.
7
+
Vamos ver mais detalhes sobre eles.
8
8
9
-
## Event: submit
9
+
## Evento: submit
10
10
11
-
There are two main ways to submit a form:
11
+
Há duas maneiras principais de enviar um formulário:
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.
13
+
1.A Primeira -- clicar em`<input type="submit">`ou`<input type="image">`.
14
+
2.A Segunda -- pressione`key:Enter`em um campo de input.
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
+
Ambas as ações levam a execução do evento `submit`no formulário. O handler pode verificar os dados, e se houver erros, será mostrado e chamado o `event.preventDefault()`, logo, o formulário não será enviado para o servidor.
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
+
No formulário abaixo:
19
+
1.Vá para o campo de texto e pressione`key:Enter`.
20
+
2.Clique em`<input type="submit">`.
21
21
22
-
Both actions show `alert`and the form is not sent anywhere due to`return false`:
22
+
Ambas as ações mostram um `alert`e o formulário não é enviado a lugar nenhum devido ao`return false`:
23
23
24
24
```html autorun height=60 no-beautify
25
25
<formonsubmit="alert('submit!');return false">
26
-
First: Enter in the input field <inputtype="text"value="text"><br>
When a form is sent using`key:Enter`on an input field, a `click`event triggers on the`<input type="submit">`.
31
+
````smart header="Relação entre`submit`e`click`"
32
+
Quando um formulário é enviado usando`key:Enter`no campo de entrada, um evento de `click`dispara no`<input type="submit">`.
33
33
34
-
That's rather funny, because there was no click at all.
34
+
Isso é até bem engraçado, porque não houve nenhum clique.
35
35
36
-
Here's the demo:
36
+
Aqui está uma demonstração:
37
37
```html autorun height=60
38
38
<formonsubmit="return false">
39
39
<inputtype="text"size="30"value="Focus here and press enter">
@@ -43,13 +43,13 @@ Here's the demo:
43
43
44
44
````
45
45
46
-
## Method: submit
46
+
## Método: submit
47
47
48
-
To submit a form to the server manually, we can call `form.submit()`.
48
+
Para enviar um formulário ao servidor manualmente, podemos chamar `form.submit()`.
49
49
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.
50
+
Nesse caso, o evento `submit` não é gerado. Podemos presumir que, se o programador chamar `form.submit()`, o script já terá realizado todo o processamento relacionado.
51
51
52
-
Sometimes that's used to manually create and send a form, like this:
52
+
Às vezes, isso é usado para criar e enviar um formulário manualmente, como este:
53
53
54
54
```js run
55
55
let form = document.createElement('form');
@@ -58,7 +58,7 @@ form.method = 'GET';
58
58
59
59
form.innerHTML = '<input name="q" value="test">';
60
60
61
-
// the form must be in the document to submit it
61
+
// o formulário deve estar incluído no documento para que ele seja enviado.
0 commit comments