Several Type of HTML5 input type attributes

This article describe you about several type of HTML5 input type attributes.
  • 1762

New Attribute for <input>

These are several type which are describe here

<input> autofocus Attribute

It is specify the input value in boolean. it is also specify that <input> element automatically

Enter First name:<input type="text" name="fname" autofocus="autofocus" />

<input> form Attribute

<!DOCTYPE html>
<html>
<body>
<form action="default.aspx" id="form1">
Enter First name: <input type="text" name="fname" /><br />
<input type="submit" value="Submit" />
</form>
<p>"Enter Last name" is declared outside the form element, but it is part of the form</p>
Enter Last name: <input type="text" name="lname" form="form1" />
</body>
</html>

<input> formaction Attribute

This attributes define the URL of the file for process on the input control when the form is submitted.

This attributes override the action attributes.

Note: It is used with the type ="submit" and type="image".

<!DOCTYPE html>
<html>
<body>

<form action="default.aspx">
Enter First name: <input type="text" name="fname" /><br />
Enter Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" /><br />
<input type="submit" formaction="default.aspx" value="Submited as admin" />
</form>

</body>
</html>


<input> formenctype Attribute

This attributes specified that how data encoded when request goes to the server.

<!DOCTYPE html>
<html>
<body>

<form action="enctype.aspx" method="post">
Enter First name: <input type="text" name="fname" /><br />
<input type="submit" value="Submit" />
<input type="submit" formenctype="differentparts/form-data" value="Submit as differentpart/form-data" />
</form>

</body>
</html>

<input> formmethod Attribute

It is define the Http method for sending form-data.

It is override the method attribute of the <form> element

Note: It is also used for type="submit" and type="image".

<!DOCTYPE html>
<html>
<body>

<form action="default.aspx" method="get">
Enter First name: <input type="text" name="fname" /><br />
Enter Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
<input type="submit" formmethod="post" formaction="default.aspx" value="Submit by POST method" />
</form>

</body>
</html>

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.