Objeto de formulário HTML DOM
Objeto de formulário
O objeto Form representa um elemento HTML <form>.
Acessar um objeto de formulário
Você pode acessar um elemento <form> usando getElementById():
Exemplo
var x = document.getElementById("myForm");
Dica: Você também pode acessar um elemento <form> usando a coleção de formulários .
Criar um objeto de formulário
Você pode criar um elemento <form> usando o método document.createElement():
Exemplo
var x = document.createElement("FORM");
Coleções de objetos de formulário
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Propriedades do objeto de formulário
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étodos de objeto de formulário
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Propriedades e eventos padrão
O objeto Form também suporta as propriedades e eventos padrão .
Páginas relacionadas
Tutorial HTML: Formulários HTML
Tutorial JavaScript: JS Forms/Validation
Referência HTML: tag HTML <form>