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
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
+
# Formulaire 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
+
Créez une fonction`showPrompt(html, callback)`qui montre un formulaire avec le message `html`, un champ de saisie et des boutons`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
+
-Un utilisateur doit taper quelque chose dans un champ de texte et appuyer sur `key:Enter`ou sur le bouton OK, puis`callback(value)`est appelé avec la valeur saisie.
10
+
-Sinon, si l'utilisateur appuie sur`key:Esc`ou CANCEL, alors`callback(null)`est appelé.
11
11
12
-
In both cases that ends the input process and removes the form.
12
+
Dans les deux cas, cela met fin au processus de saisie et supprime le formulaire.
13
13
14
-
Requirements:
14
+
Conditions:
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
+
-Le formulaire doit être au centre de la fenêtre.
17
+
-Le formulaire est*modal*. En d'autres termes, aucune interaction avec le reste de la page n'est possible tant que l'utilisateur ne la ferme pas.
18
+
-Lorsque le formulaire est affiché, le focus doit être à l'intérieur de `<input>`pour l'utilisateur.
19
+
-Les touches `key:Tab`/`key:Shift+Tab`devraient déplacer le focus entre les champs du formulaire, ne pas lui permettre de partir pour d'autres éléments de la page.
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/4-forms-submit/article.md
+21-23Lines changed: 21 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,23 @@
1
-
# Forms: event and method submit
1
+
# Formulaires: l'événement et la méthode "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
+
L'événement`submit`se déclenche lorsque le formulaire est soumis, il est généralement utilisé pour valider le formulaire avant de l'envoyer au serveur ou pour abandonner la soumission et la traiter en 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
+
La méthode`form.submit()`permet de lancer l'envoi de formulaire depuis JavaScript. Nous pouvons l'utiliser pour créer et envoyer dynamiquement nos propres formulaires au serveur.
6
6
7
-
Let's see more details of them.
7
+
Voyons-les plus en détail.
8
8
9
-
## Event: submit
9
+
## Évènement: submit
10
10
11
-
There are two main ways to submit a form:
11
+
1. Le premier - cliquer sur `<input type="submit">` ou `<input type="image">`.
12
+
2. La seconde - appuyez sur `key:Enter` dans un champ de saisie.
12
13
13
-
1. The first -- to click `<input type="submit">` or `<input type="image">`.
14
-
2. The second -- press `key:Enter` on an input field.
14
+
Les deux actions mènent à l'événement `submit` sur le formulaire. Le gestionnaire peut vérifier les données, et s'il y a des erreurs, les afficher et appeler `event.preventDefault()`, alors le formulaire ne sera pas envoyé au serveur.
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
+
Dans le formulaire ci-dessous:
17
+
1. Allez dans le champ de texte et appuyez sur `key:Enter`.
18
+
2. Cliquez sur `<input type ="submit">`.
17
19
18
-
In the form below:
19
-
1. Go into the text field and press `key:Enter`.
20
-
2. Click `<input type="submit">`.
21
-
22
-
Both actions show `alert` and the form is not sent anywhere due to `return false`:
20
+
Les deux actions affichent `alert` et le formulaire n'est envoyé nulle part en raison de `return false`:
23
21
24
22
```html autorun height=60 no-beautify
25
23
<formonsubmit="alert('submit!');return false">
@@ -28,12 +26,12 @@ Both actions show `alert` and the form is not sent anywhere due to `return false
Lorsqu'un formulaire est envoyé en utilisant`key:Enter`sur un champ de saisie, un événement `click`se déclenche sur`<input type="submit">`.
33
31
34
-
That's rather funny, because there was no click at all.
32
+
C'est plutôt drôle, car il n'y a pas eu de clic du tout.
35
33
36
-
Here's the demo:
34
+
Voici la démo:
37
35
```html autorun height=60
38
36
<formonsubmit="return false">
39
37
<inputtype="text"size="30"value="Focus here and press enter">
@@ -43,13 +41,13 @@ Here's the demo:
43
41
44
42
````
45
43
46
-
## Method: submit
44
+
## Méthode: submit
47
45
48
-
To submit a form to the server manually, we can call `form.submit()`.
46
+
Pour soumettre manuellement un formulaire au serveur, nous pouvons appeler `form.submit()`.
49
47
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.
48
+
Ensuite, l'événement `submit` n'est pas généré. On suppose que si le programmeur appelle `form.submit()`, alors le script a déjà effectué tous les traitements associés.
51
49
52
-
Sometimes that's used to manually create and send a form, like this:
50
+
Parfois, cela est utilisé pour créer et envoyer manuellement un formulaire, comme ceci:
53
51
54
52
```js run
55
53
let form = document.createElement('form');
@@ -58,7 +56,7 @@ form.method = 'GET';
58
56
59
57
form.innerHTML = '<input name="q" value="test">';
60
58
61
-
// the form must be in the document to submit it
59
+
// le formulaire doit être dans le document pour le soumettre
0 commit comments