HTML Form

HTML Form is used to collect data from user and submit it to server for processing data. Html <form> tag is used to collect data from user.

An HTML form contains input controls such as text fields, textarea, password fields, check boxes, radio buttons, submit button, combo box etc.

A submit button sends html form 's data to server.

HTML Form Syntax :

<form action="" method="" enctype="multipart/form-data" name="">
</form>

 

HTML Form  Attributes

Html Form Attributes
Attributes Description
action Set page url to process input data. It is called as form-handler .
method Set GET and POST methods.
target Specify traget values such as _blank, _self, _parent
enctype Specify how the browser encodes the data before it sends it to the server. Enctype values are application/x-www-form-urlencoded and multipart/form-data. multipart/form-data is used to upload files into server.
name Specify form name.
class Specify class name which is used to apply css style to form.
onsubmit It is used to perform action using javascript when submit event is occuered.
onclick  It is used to perform action using javascript when click event is occuered.
   

 

HTML 5 form control tags

Let's see below HTML 5 control tags which can used to collect data using HTML form.

  1. Text Input Controls : <input type="text" name="" value="" />
  2. Checkboxes Controls : <input type="checkbox" name="" value="" />
  3. Radio Box Controls : <input type="radio" name="" value="" />
  4. Select Box Controls : <select name=""><option value="">some text</option></select>
  5. File Select boxes :<input type="file" name="" value="" />
  6. Hidden Controls : <input type="hidden" name="" value="" />
  7. Password Controls: <input type="password" name="" value="" />
  8. Clickable Buttons : <button name="" value=""></button>
  9. Submit and Reset Button : <input type="submit" name="" value="" />

 

HTML 5 form control tags
HTML Tags Description
<input> It is used to define text field, submit button, radio button, password field, email field, color field, hidden field, file field.
<select> It is used to define drop-down list.
   
<button> It is used to define clickable button for submitting form.
<option> It is used to define value for drop-down list.
<optgroup> It is used to define a group of related options in a drop-down list.
<textarea> It is used to define multi-line input control.

 

Let's see example for html form.

Example :

<html>
<head>
<title>Learn HTML Form by aryatechno</title>
</head>
<body>
<h2>Registration Form using HTML form</h2>
<div class="content">
<form action="" method="post" aenctype="multipart/form-data" name="register">
<p>
<label for="fullname">Enter Name :</label>
<input type="text" name="fullname" id="fullname" value="" />
</p>

<p>
<label for="mobile">Enter Mobile Number :</label>
<input type="text" name="Mobile" id="Mobile" value="" />
</p>

<p>
<label for="Email">Enter Email :</label>
<input type="email" name="Email" id="Email" value="" />
</p>

<p>
<label for="Password">Enter Password :</label>
<input type="password" name="Password" id="Password" value="" />
</p>

<p>
<label for="Address">Enter Address :</label>
<input type="text" name="Address" id="Address" value="" />
</p>

<p>
<label for="Gender">Enter Gender :</label>
<input type="radio" name="Gender" id="Male" value="Male" /> Male <input type="radio" name="Gender" id="Female" value="Female" /> Female
</p>


<p>
<label for="Country">Enter Country :</label>
<select name="Country">
<option value="India">India</option>
<option value="China">China</option>
<option value="Canada">Canada</option>
<option value="USA">USA</option>
</select>
</p>

<p>
<input type="submit" name="Submit" value="Submit" />
</p>

</form>
</div>

</body>
</html>

Output :

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

67393