Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

HTML Form Attributes:

certainly! Here are some commonly used attributes for HTML forms:

  1. action: Specifies the URL where the form data will be sent when the form is submitted.

  2. method: Specifies the HTTP method to be used when submitting the form. It can be "get" or "post". The "get" method appends the form data to the URL, while the "post" method sends the data in the request body.

  3. name: Gives a name to the form. This attribute is useful when referencing the form in JavaScript.

  4. target: Specifies where to display the response received after submitting the form. It can be "_blank" (opens in a new window), "_self" (opens in the same frame or window), "_parent" (opens in the parent frame), or "_top" (opens in the full body of the window).

  5. autocomplete: Indicates whether the browser should autocomplete the form inputs. It can be set to "on" or "off".

  6. enctype: Specifies the content type used to encode the form data before submitting it to the server. It is required when the method is "post" and the form contains file uploads. Common values are "application/x-www-form-urlencoded", "multipart/form-data", and "text/plain".

  7. novalidate: Specifies that the form should not be validated when submitted. This is useful when you want to bypass browser validation and perform custom validation using JavaScript.

  8. accept-charset: Specifies the character encodings that are accepted for form submission. It is used with the "method" attribute set to "post".

  9. onsubmit: Specifies a JavaScript function to be executed when the form is submitted.

  10. onreset: Specifies a JavaScript function to be executed when the form is reset.

Here's an example demonstrating the usage of these attributes:

<form action="/submit-form" method="post" name="myForm" target="_blank" autocomplete="off" enctype="multipart/form-data" novalidate accept-charset="UTF-8" onsubmit="return validateForm()">
<!-- Form inputs go here -->
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>

Each of these attributes allows you to control various aspects of how the form behaves and interacts with the user and server.




Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java