Objeto de formulario HTML DOM
Objeto de formulario
El objeto Form representa un elemento HTML <form>.
Acceder a un objeto de formulario
Puede acceder a un elemento <form> usando getElementById():
Ejemplo
var x = document.getElementById("myForm");
Sugerencia: también puede acceder a un elemento <form> utilizando la colección de formularios .
Crear un objeto de formulario
Puede crear un elemento <form> utilizando el método document.createElement():
Ejemplo
var x = document.createElement("FORM");
Colecciones de objetos de formulario
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Propiedades del objeto de formulario
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 formulario
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Propiedades y eventos estándar
El objeto Form también es compatible con las propiedades y eventos estándar .
páginas relacionadas
Tutorial de HTML: formularios HTML
Tutorial de JavaScript: Formularios JS/Validación
Referencia HTML: etiqueta HTML <formulario>