Loading Please Wait...

Logo Lynxsia IT Solutions

HTML Input From Attributes

HTML Input Form Attributes

HTML input elements have some attributes which is used to refer the form it belongs to and modify form properties. These input form attributes overrides the default value of the form element itself.

form Attribute

The form attribute defines the form an input element belongs to. The value of the form attribute is same as the id of the form element. This is helpful when we have input element outside the form and want to submit its value along with the form.

Let's see with some example
					 
        
          <form id="myForm">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit">
          </form>

          <label for="phone">Phone:</label>
          <input type="tel" name="phone" id="phone" form="myForm">
        
      
formaction Attribute

The formaction attribute defines the action of the form when form is submitted. It overrides the action attribute of the form element. This will work only with submit and image input types that trigger the form submission.

Let's see with some example
					 
        
          <form action="server1.php">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit" formaction="server2.php">
          </form>
        
      
formenctype Attribute

The formenctype attribute defines the encoding of the data when form is submitted.

Let's see with some example
					 
        
          <form action="server.php">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit" formenctype="multipart/form-data">
          </form>
        
      
formmethod Attribute

The formmethod attribute defines the get or post method of the form.

Let's see with some example
					 
        
          <form action="server.php">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit">
            <input type="submit" formmethod="post">
          </form>
        
      
formtarget Attribute

The formtarget attribute defines location of the response display after form is submitted.

Let's see with some example
					 
        
          <form action="server.php">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit">
            <input type="submit" formtarget="_top">
          </form>
        
      
formnovalidate Attribute

The formnovalidate attribute defines that the input element should not be validated when form is submitted.

Let's see with some example
					 
        
          <form action="server.php">
            <label for="name">Name:</label>
            <input type="text" name="name" id="name">
            <label for="email">Email:</label>
            <input type="email" name="email" id="email">
            <input type="submit">
            <input type="submit" formnovalidate="formnovalidate">
          </form>
        
      

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