Loading Please Wait...

Logo Lynxsia IT Solutions

HTML Form Attributes

HTML Form Attributes

HTML From attributes allow us to defined additional properties to HTML <form> such as where to send the form data (server path), data encryption, data type, etc.

Action Attribute

The action attribute defines the action taken when the form is submitted usually by clicking submit button.

In most of the cases, the form data is sent to the server for further processing

If the action attribute is not defined then the form data is sent to the current page when submitting the form.

Let's see with some example
					 
        
          <form action="server.php">
            <label for="email">Email</label><br>
            <input type="email" id="email"><br>
            <input type="submit" value="Submit">
          </form>
        
      
Target Attribute

The target attribute defines the location to show the data received from the server after the form is submitted.

It may have the following values:

_blank - In new window

_self - In current window (Default)

_parent - In parent frame window

_top - In full body window

framename - In named frame

Let's see with some example
					 
        
          <form action="server.php" target="_top">
        
      
Method Attribute

The method attribute defines the method type when submitted the data.

It may have either get (default) or post

method="get"

  • The form data is added to the action URL, as name=value pair.
  • It is insecure as form data is visible on the URL.
  • Do not use this method if the form contains the sensitive data such as email, password.
  • It is also notable that the URL can only contains 2048 characters. All the data after 2048 character will be omitted If URL is to long.

method="post"

  • The form data is added to body of the request.
  • It is secure as form data is not visible.
  • Use this for submitting sensitive information.
  • You can also send large amount of the hence there is no limitation.
Let's see with some example
					 
        
          <form action="server.php" method="post">
        
      
Autocomplete Attribute

The autocomplete attribute defines the auto completion of the form data when entering some value like email.

It will show suggestion such as name, email, we have filled before.

It may have on (default) or off values. Sensitive input fields like password must have autocomplete off value.

Let's see with some example
					 
        
          <form action="server.php" autocomplete="off">
        
      
Novalidate Attribute

The novalidate attribute defines that the form data should not be validated like email.

Let's see with some example
					 
        
          <form action="server.php" novalidate>
        
      
Enctype Attribute

The enctype attribute defines the data encoding method when submitting form.

This must be used only when method="post"

It may have the following values:

application/x-www-form-urlencoded - Data is encoded and special characters are converted to ASCII hex values (Default).

multipart/form-data - Use this if the form contains file like image upload. Data encoding done as well.

text/plain - No data encoding, try not to use.

Let's see with some example
					 
        
          <form action="server.php" enctype="multipart/form-data">
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved