<form> element represents the form and inherits the HTMLFormElement interface.
HTMLFormElement instance attributes
elements: returns an array-like object, the members are all control elements belonging to the form. This attribute is read-only. -
length: Returns an integer, indicating the number of controls belonging to the form. This attribute is read-only. -
name: A string that represents the name of the form. -
method: A string indicating the HTTP method used when submitting to the server. -
target: A string representing the display position of the data returned by the server after the form is submitted. -
action: A string representing the URL of the form submission data. -
encoding): string, representing the encoding method of form submission data, possible values are
text/plain . -
acceptCharset: string, representing the character encoding that the server can accept. Multiple encoding formats are separated by commas or spaces. -
autocomplete: the string
off, indicating whether the browser should provide automatic completion for the
<input> control. -
noValidate: Boolean value, indicating whether to turn off the automatic verification of the form.
HTMLFormElement instance method
submit(): Submit the form, but the
submit event and automatic verification of the form will not be triggered. -
reset(): Reset the value of the form control to the default value. -
checkValidity(): If the control can pass the automatic verification, return
true, otherwise return
false, and trigger the
invalid event at the same time.
Below is an example of creating a form and submitting it.
var f = document.createElement("form"); document.body.appendChild(f); f.action = "/cgi-bin/some.cgi"; f.method = "POST"; f.submit();