HTML-DOM - Formularobjekt
Formularobjekt
Das Form-Objekt repräsentiert ein HTML-<form>-Element.
Greifen Sie auf ein Formularobjekt zu
Sie können auf ein <form>-Element zugreifen, indem Sie getElementById() verwenden:
Beispiel
var x = document.getElementById("myForm");
Tipp: Sie können auch auf ein <form>-Element zugreifen, indem Sie die Forms- Sammlung verwenden.
Erstellen Sie ein Formularobjekt
Sie können ein <form>-Element erstellen, indem Sie die Methode document.createElement() verwenden:
Beispiel
var x = document.createElement("FORM");
Objektsammlungen bilden
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Eigenschaften von Formularobjekten
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 |
Formularobjektmethoden
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Standardeigenschaften und -ereignisse
Das Form-Objekt unterstützt auch die Standardeigenschaften und -ereignisse .
Verwandte Seiten
HTML-Tutorial: HTML-Formulare
JavaScript-Tutorial: JS-Formulare/Validierung
HTML-Referenz: HTML <form>-Tag