Объект формы HTML DOM
Объект формы
Объект Form представляет элемент HTML <form>.
Доступ к объекту формы
Вы можете получить доступ к элементу <form> с помощью getElementById():
Пример
var x = document.getElementById("myForm");
Совет: Вы также можете получить доступ к элементу <form>, используя коллекцию форм .
Создать объект формы
Вы можете создать элемент <form> с помощью метода document.createElement():
Пример
var x = document.createElement("FORM");
Коллекции объектов формы
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Свойства объекта формы
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 |
Методы объекта формы
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Стандартные свойства и события
Объект Form также поддерживает стандартные свойства и события .
Связанные страницы
Учебник по HTML: HTML-формы
Учебник по JavaScript: JS Forms/Validation
Справочник по HTML: HTML-тег <form>