Form
Form
Part 2
Form-text box
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname"
name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
Form-Radio button
Target
The target attribute specifies if the submitted result will open in a new
browser tab, a frame, or in the current window.
The default value is "_self" which means the form will be submitted in
the current window.
To make the form result open in a new browser tab, use the value
"_blank
Method Attribute
When to Use GET?
Notes on POST:
Appends the form data inside the body of the HTTP request.
POST has no size limitations, and can be used to send large amounts of
data.
Form submissions with POST cannot be bookmarked
The Name Attribute
Each input field must have a name attribute to be submitted.
If the name attribute is omitted, the data of that input field will not be
sent at all.
Form- AutoComplete
<form action="/action_page.php" autocomplete="on" >
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
Form-checkbox
<form action="">
First name:<br>
<input type="text" name="firstname"
value="John" readonly>
</form>
The autofocus Attribute
<form action="/action_page.php">
First name:<input type="text" name="fname"
autofocus><br>
Last name: <input type="text"
name="lname"><br>
<input type="submit">
</form>
The pattern Attribute
The pattern attribute specifies a regular expression that the <input> element's value is
checked against.
The pattern attribute works with the following input types: text, search, url, tel, email,
and password.
<form action="/action_page.php">
Country code: <input type="text"
name="country_code" pattern="[A-Za-z]{3}"
title="Three letter country code">
<input type="submit">
</form>