HTML Input Form's Attributes
HTML
The <input>
has some attributes related to form that also a developer must know about.
Most common input Attributes for form
form
, formaction
,
formmethod
, formtarget
,
formnovalidate
, formenctype
etc.
form
attribute of <input>
tag
form
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
formaction
attribute of <input>
tag
formaction
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
formmethod
attribute of <input>
tag
formmethod
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
formtarget
attribute of <input>
tag
formtarget
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
formnovalidate
attribute of <input>
tag
formnovalidate
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
formenctype
attribute of <input>
tag
formenctype
attribute specifies the initial value of a input.
It is the default value for the input if the user do not type / change anything in the input.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.