Form Handling
JavaScript provides access to the forms within an HTML document through the Form object known as HTMLFormElement in the DOM. Which is a child of the Document Object.
Properties
| Properties | Value | Description |
| accept-charset | UTF-8 | Specifies the charset used in the submitted form (default: the page charset). |
| action | URL | Contains a URL that defines where to send the data after submitting the form |
| autocomplete | On (default) Off | Determines that the browser retains the history of previous values. |
| enctype | specifies how the browser encodes the data before it sends it to the server. (default: is url-encoded). | |
| encoding | Holds the value of the enctype attribute, which usually contains either application/x-www-form-urlencoded value or the multipart/form-data value (in the case of file upload) | |
| elements[ ] | An array of DOM elements that correspond to the interactive form fields within the form |
Properties
| Properties | Value | Description |
| length | The number of a form field with a given form tag. Should bt the same as elements.length | |
| method | GET (default) POST | Specifies how to send the form data to a web server. The data can be sent as URL variables, by using the get method or as HTTP post, by using the post method |
| name | name | Specifies a name used to identify the form |
| novalidate | novalidate | Specifies that the browser should not validate the form. |
| target | _self (default) _blank _parent _top framename | Specifies the target of the address in the action attribute |
Methods
| Method | Description |
| checkValidity ( ) | Returns a true or false value indicating whether or not all the fields in the form are in a valid state. |
| reset ( ) | Returns all form fields to their initial state. |
| submit ( ) | Submits the form to the URL specified in the formβs action attribute |
Events: –
- onreset
- onsubmit
Latest posts by rajeshkumar (see all)
- The Three Pillars of Digital Resilience in 2025: Database Administration, Cybersecurity, and Vulnerability Assessment - September 24, 2025
- Avionics Technician: The Backbone of Modern Aviation - September 12, 2025
- Top 20 Computer Vision Libraries - August 26, 2025