The HTML <input type="submit"> element is used to create a submit button in a form. It sends the form data to the server when clicked.
- Used to submit form data to the server.
- Created using <input type="submit"> inside a <form> element.
- Supports attributes like value, disabled, and formaction.
Syntax:
<input type="submit">
Attributes
- value: Specifies the text displayed on the submit button.
- name: Defines a name for the submit button used in form data.
- disabled: disabled disables the submit button and prevents form submission.
- form: Specifies the form associated with the submit button.
- formaction: formaction defines the URL where form data is sent for processing.
- formenctype:formenctype specifies how form data should be encoded before submission.
- formmethod: formmethod specifies the HTTP method (GET or POST) used for form submission.
- formtarget: formtarget specifies where to display the response after form submission.
- autofocus:autofocus automatically focuses the submit button when the page loads.
- formnovalidate: formnovalidate prevents form validation during form submission.
Note: The form handler is defined in the action attribute of the form.
Example: We are using the HTML <input type="submit"> to create a submit button for a form. When clicked, it submits the form data (username and password) to the server for processing.