Obiekt formularza HTML DOM
Obiekt formularza
Obiekt Form reprezentuje element HTML <form>.
Uzyskaj dostęp do obiektu formularza
Możesz uzyskać dostęp do elementu <form> za pomocą getElementById():
Przykład
var x = document.getElementById("myForm");
Porada: Możesz również uzyskać dostęp do elementu <form> przy użyciu kolekcji formularzy .
Utwórz obiekt formularza
Możesz utworzyć element <form> za pomocą metody document.createElement():
Przykład
var x = document.createElement("FORM");
Kolekcje obiektów formularza
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
Właściwości obiektu formularza
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 obiektów formularza
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
Standardowe właściwości i zdarzenia
Obiekt Form obsługuje również standardowe właściwości i zdarzenia .
Powiązane strony
Samouczek HTML: formularze HTML
Samouczek JavaScript: formularze/walidacja JS
Odniesienie HTML: tag HTML <form>