Objekt formuláře HTML DOM
Objekt formuláře
Objekt Form představuje HTML element <form>.
Přístup k objektu formuláře
K prvku <form> můžete přistupovat pomocí getElementById():
Příklad
var x = document.getElementById("myForm");
Tip: K prvku <form> můžete také přistupovat pomocí kolekce formulářů .
Vytvořte objekt formuláře
Element <form> můžete vytvořit pomocí metody document.createElement():
Příklad
var x = document.createElement("FORM");
Kolekce objektů formuláře
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Vlastnosti objektu formuláře
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 |
Metody objektů formuláře
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Standardní vlastnosti a události
Objekt Form také podporuje standardní vlastnosti a události .
Související stránky
HTML výukový program: HTML formuláře
JavaScript výukový program: JS Forms/Validation
HTML reference: HTML tag <form>