Skip to content

Commit bdf55f4

Browse files
committed
feat: Forms: event and method submit | Translation done
1 parent b464ad1 commit bdf55f4

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

2-ui/4-forms-controls/4-forms-submit/article.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
# Forms: event and method submit
1+
# Formulários: evento e método submit
22

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.
44

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.
66

7-
Let's see more details of them.
7+
Vamos ver mais detalhes sobre eles.
88

9-
## Event: submit
9+
## Evento: submit
1010

11-
There are two main ways to submit a form:
11+
Há duas maneiras principais de enviar um formulário:
1212

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.
1515

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.
1717

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">`.
2121

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`:
2323

2424
```html autorun height=60 no-beautify
2525
<form onsubmit="alert('submit!');return false">
26-
First: Enter in the input field <input type="text" value="text"><br>
27-
Second: Click "submit": <input type="submit" value="Submit">
26+
Primeiro: Insira no campo de entrada <input type="text" value="text"><br>
27+
Segundo: Clique em "submit": <input type="submit" value="Submit">
2828
</form>
2929
```
3030

31-
````smart header="Relation between `submit` and `click`"
32-
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">`.
3333

34-
That's rather funny, because there was no click at all.
34+
Isso é até bem engraçado, porque não houve nenhum clique.
3535

36-
Here's the demo:
36+
Aqui está uma demostração:
3737
```html autorun height=60
3838
<form onsubmit="return false">
3939
<input type="text" size="30" value="Focus here and press enter">
@@ -43,13 +43,13 @@ Here's the demo:
4343

4444
````
4545
46-
## Method: submit
46+
## Método: submit
4747
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()`.
4949
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.
5151
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:
5353
5454
```js run
5555
let form = document.createElement('form');
@@ -58,7 +58,7 @@ form.method = 'GET';
5858
5959
form.innerHTML = '<input name="q" value="test">';
6060
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.
6262
document.body.append(form);
6363
6464
form.submit();

0 commit comments

Comments
 (0)