HTML Form Attributes

Form Attributes

  • Type Attribute
    - It indicates the type of input element. It’s an empty tag. The default value is text.
    <input type=“text”>


  • Accept-charset Attribute
    - It specifies the character encodings that are to be used for the form submission.
    ISO-8859-1 Character encoding for the Latin alphabet
    UTF-8 Character encoding for Unicode
    <form accept-charset=“UTF-8”>


  • Action Attribute
    - It contains a URL that defines where to send the data after submitting the form.
    It specifies the physical address of the server to which the user data should be redirected at the click of the submit button.
    action=http://www.something.com/something.php
    action=“page.php”
    action=“gotform.php”
    action=“example.asp”


  • Autocomplete Attribute
    On – The browser will automatically complete values based on values that the user has entered before.
    Off – User need to write all values each time they fill the form.
    <form autocomplete=“on”>


  • Enctype Attribute
    - It specifies how the browser encodes the data before it sends it to the server.
    <form enctype=“multipart/form-data”>


  • Method Attribute
    - It 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.

    GET
    - GET sends the data as part of the URL.
    1. Appends form-data into the URL in name/value pairs
    2. The length of a URL is limited 2048 characters
    3. Never use GET method if you have password or other sensitive information to be sent to the server.
    4. Useful for form submissions where a user want to bookmark the result
    5. GET is better for non-secure data, like query strings in Google
    6. GET can't be used to send binary data, ex:- images or word documents
    <form action=“some.php” method = “GET”>

    POST
    - HTTP POST requests supply additional data from the client (browser) to the server in the message body.
    1. Appends form-data inside the body of the HTTP request (data is not shown is in URL)
    2. The POST method does not have any restriction on data size to be sent.
    3. Form submissions with POST cannot be bookmarked
    4. The POST method can be used to send ASCII as well as binary data. Ex:- image and word documents etc
    5. The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
    6. POST is a little safer than GET because the parameters are not stored in browser history or in web server logs
    <form action=“some.php” method = “POST”>


  • Name Attribute
    - It is Used to give a name to the control which is sent to the server to be recognized and get the value.
    name=“lastname”


  • Novalidate Attribute
    - If we use novalidate attribute in form tag then the validation will not take place, even if there is a required filed.
    <form novalidate>
    <form novalidate=“novalidate”>
    <form novalidate=“true”>
    - There is one more tag formnovalidate which is used by input tag to speficiy novlidate this particular text or field we will study about this later.


  • Text Direction (dirname) Attribute
    - Specifies that the text direction will be submitted
    <input type=“text” name=“city” dirname=“city.dir”>





Cristle Academy

Compiler