In HTML a form can be made using
Inside the form tag there are many input tags like email, text, password, phone, select, textarea etc.
The input element creates an input box in the form. There are many types of input boxes.
Input type number
Input type email
Input type Tel
Input type color
Input type range
Input type time
Input type date
Input type Select
Input type Radio
Female
Other
Input type CheckBox
Tweet on twitter
Input type Submit
Input type Reset
The name attribute specifies name for form and inputs such that they can be accessed by backend program.
For advanced forms visit here
This attrubute tells the browser to not submit the form unless the input is filled or a checkbox or radio is filled.
The <fieldset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
form
tag. It is a container tag.Inside the form tag there are many input tags like email, text, password, phone, select, textarea etc.
Form example
HTML
We use <body> <form> ••• </form> </body>
action
attribute to point to a webpage that will load when the user clicks submit button.
HTML
<form action="query.php"> ••• </form>
When use GET the form data will be visible in page address.
HTML
<form action="url" method="get"></form>
Use POST if the form is updating data or includes like password.
HTML
<form action="url" method="POST"></form>
Remember: Default value of method attribute is get , hence the form value will be visible in address bar.
Input tag
The input element creates an input box in the form. There are many types of input boxes.
HTML
Other possible values for type attribute are color, date, search, week, datetime, month, tel, datetime-local, number, time, email, range and url.<form> <input type="text"> <input type="password"> </form>
Examples
Input type number
HTML
<input type="number"/>
Input type email
HTML
<input type="email"/>
Input type Tel
HTML
<input type="tel"/>
Input type color
HTML
<input type="color"/>
Input type range
HTML
<input type="range"/>
Input type time
HTML
<input type="time"/>
Input type date
HTML
<input type="date"/>
Input type Select
HTML
<select> <option value="apple">Apple</option> <option value="samsung">Samsung</option> <option value="nokia">Nokia</option> <option value="verizon">Verizon</option> </select>
Input type Radio
HTML
Male<input type="radio" name="gender" value="male" checked> Male<br> <input type="radio" name="gender" value="female"> Female<br> <input type="radio" name="gender" value="other"> Other
Female
Other
Input type CheckBox
HTML
Share on facebook<input type="checkbox" name="medium" value="facebook" checked> Share on facebook<br> <input type="checkbox" name="medium" value="twitter"> Tweet on twitter<br>
Tweet on twitter
Input type Submit
HTML
<input type="submit" name="submit" value="Send">
Input type Reset
Clears entire form (all inputs)
HTML
<input type="reset" name="reset" value="Clear">
Name attribute
The name attribute specifies name for form and inputs such that they can be accessed by backend program.
For advanced forms visit here
HTML
<form> <input type="text" name="username"/> <input type="password" name="password"/> </form>
Required Attribute
This attrubute tells the browser to not submit the form unless the input is filled or a checkbox or radio is filled.
HTML
<input type="number" required/>
Fieldset
The <fieldset> element is used to group related data in a form.
The <legend> element defines a caption for the <fieldset> element.
HTML
<form action="action.php"> <fieldset> <legend>User Information:</legend> First name:<br> <input type="text" name="firstname" value="John"><br> Last name:<br> <input type="text" name="lastname" value="Doe"><br><br> <input type="submit" value="Submit"> </fieldset> </form>
Comments
Post a Comment