Objet de formulaire HTML DOM
Objet de formulaire
L'objet Form représente un élément HTML <form>.
Accéder à un objet de formulaire
Vous pouvez accéder à un élément <form> en utilisant getElementById() :
Exemple
var x = document.getElementById("myForm");
Conseil : Vous pouvez également accéder à un élément <form> en utilisant la collection de formulaires .
Créer un objet de formulaire
Vous pouvez créer un élément <form> en utilisant la méthode document.createElement() :
Exemple
var x = document.createElement("FORM");
Collections d'objets de formulaire
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Propriétés de l'objet de formulaire
Property | Description |
---|---|
acceptCharset | Sets or returns the value of the accept-charset attribute in a form |
action | Sets or returns the value of the action attribute in a form |
autocomplete | Sets or returns the value of the autocomplete attribute in a form |
encoding | Alias of enctype |
enctype | Sets or returns the value of the enctype attribute in a form |
length | Returns the number of elements in a form |
method | Sets or returns the value of the method attribute in a form |
name | Sets or returns the value of the name attribute in a form |
noValidate | Sets or returns whether the form-data should be validated or not, on submission |
target | Sets or returns the value of the target attribute in a form |
Méthodes d'objet de formulaire
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Propriétés et événements standard
L'objet Form prend également en charge les propriétés et événements standard .
Pages connexes
Tutoriel HTML : Formulaires HTML
Tutoriel JavaScript : Formulaires JS/Validation
Référence HTML : balise HTML <form>