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/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 é eviado 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 demostraçã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