Wednesday, 24 June 2015

Form tag in HTML

Form tag:

             Using form tag, we can get input values from the user by allowing them to submit the form. Form tag may optionally contain the following elements.
             

  • <input>
  • <select>
  • <option>
  • <optgroup>
  • <textarea>
  • <button>
  • <fieldset>
  • <label>
Simple registration form using form element without validation:

<html>
<head>
<title>The Student Registration Form</title>
</head>
<body bgcolor=aqua>
<center><h3>Registration Form</h3></center>
<form name=my_form onsubmit=validate()>
<strong>Name:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
</strong>
<input type=text name=name><br/>
<br>
<br>
<strong>Age:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong>
<input type=text name=Age_txt><br/>
<br>
<br>
<strong>Phone No:&nbsp</strong>
<input type=text name=ph_txt><br/>
<br>
<Br>
<strong>Gender:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </strong>
<input type="radio" name="group1" value="Male">Male&nbsp&nbsp&nbsp&nbsp
<input type="radio" name="group1" value="Female">Female<br/><br/><br/>
<strong>Hobby: </strong>
&nbsp&nbsp
<input type="checkbox" name ="option1" value="Singing">Singing<br/>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<input type="checkbox" name ="option1" value="Reading">Reading<br/>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<input type="checkbox" name ="option1" value="T.V.">Watching T.V<br/>
<br/><br/>
<strong>Country:</strong>
<select name="My_Menu">
<option value="India">India</option>
<option value="China">China</option>
<option value="Shrilanka">Shrilanka</option>
</select>
<center>
<input type=submit value=Submit></br>
</center>
</body>
</html>


Sample output:



No comments:

Post a Comment