WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML Input Attributes


The esteem Attribute

The value trait indicates the underlying worth for an info field:

Example

<form action="">
First name:<br>
<input type="text" name="firstname" value="John">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »

The readonly Attribute

The readonly quality determines that the information field is peruse just (can't be changed):

Example

<form action="">
First name:<br>
<input type="text" name="firstname" value="John" readonly>
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »

The readonly quality does not require an esteem. It is equivalent to composing readonly="readonly".


The crippled Attribute

The disabled quality determines that the info field is disabled.

A crippled component is un-usable and un-clickable.

Disabled components won't be submitted.

Example

<form action="">
First name:<br>
<input type="text" name="firstname" value="John" disabled>
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »

The crippled quality does not require an esteem. It is equivalent to composing disabled="disabled".


The estimate Attribute

The size property determines the size (in characters) for the info field:

Example

<form action="">
First name:<br>
<input type="text" name="firstname" value="John" size="40">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »

The maxlength Attribute

The maxlength quality indicates the greatest permitted length for the info field:

Example

<form action="">
First name:<br>
<input type="text" name="firstname" maxlength="10">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »

With a maxlength quality, the info control won't acknowledge more than the permitted number of characters.

The trait does not give any input. On the off chance that you need to alarm the client, you should compose JavaScript code.

HTML5 Attributes

HTML5 included the accompanying characteristics for <input>:

  • autocomplete
  • autofocus
  • form
  • formaction
  • formenctype
  • formmethod
  • formnovalidate
  • formtarget
  • height and width
  • list
  • min and max
  • multiple
  • pattern (regexp)
  • placeholder
  • required
  • step

and the accompanying characteristics for <form>:

  • autocomplete
  • novalidate

The autocomplete Attribute

The autocomplete characteristic indicates whether a structure or information field ought to have autocomplete on or off.

When autocomplete is on, the program naturally total qualities dependent on qualities that the client has entered before.

Tip: It is conceivable to have autocomplete "on" for the structure, and "off" for explicit info fields, or bad habit versa.

The autocomplete quality works with <form> and the following <input> types: content, look, url, tel, email, secret key, datepickers, run, and color.

Opera Safari Chrome Firefox Internet Explorer

Example

An HTML structure with autocomplete on (and off for one info field):

<form action="action_page.php" autocomplete="on">
  First name:<input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  Email: <input type="email" name="email" autocomplete="off"><br>
  <input type="submit">
</form>
Try it Yourself »

Tip: In certain programs you may need to enact the autocomplete work for this to work.


The novalidate Attribute

The novalidate characteristic is a <form> attribute.

When present, novalidate determines that structure information ought not be approved when submitted.

Opera Safari Chrome Firefox Internet Explorer

Example

Indicates that the structure isn't to be approved on submit:

<form action="action_page.php" novalidate>
  Email: <input type="email" name="user_email">
  <input type="submit">
</form>
Try it Yourself »

The self-adjust Attribute

The self-adjust characteristic is a boolean attribute.

When present, it determines that a <input> component ought to naturally get center when the page loads.

Opera Safari Chrome Firefox Internet Explorer

Example

Let the "First name" input field consequently get center when the page loads:

First name:<input type="text" name="fname" autofocus>
Try it Yourself »

The structure Attribute

The structure property indicates at least one structures a <input> component has a place to.

Tip: To allude to more than one structure, utilize a space-isolated rundown of structure ids.

Opera Safari Chrome Firefox Internet Explorer

Example

An input field situated outside the HTML structure (yet at the same time a piece of the form):

<form action="action_page.php" id="form1">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
</form>

Last name: <input type="text" name="lname" form="form1">
Try it Yourself »

The formaction Attribute

The formaction trait determines the URL of a record that will procedure the information control when the structure is submitted.

The formaction trait abrogates the activity quality of the <form> element.

The formaction trait is utilized with type="submit" and type="image".

Opera Safari Chrome Firefox Internet Explorer

Example

An HTML structure with two submit catches, with various actions:

<form action="action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit"><br>
  <input type="submit" formaction="demo_admin.asp"
  value="Submit as admin">
</form>
Try it Yourself »

The formenctype Attribute

The formenctype trait indicates how the structure information ought to be encoded while submitting it to the server (just for structures with method="post").

The formenctype property abrogates the enctype characteristic of the <form> element.

The formenctype property is utilized with type="submit" and type="image".

Opera Safari Chrome Firefox Internet Explorer

Example

Send structure information that is default encoded (the first submit catch), and encoded as "multipart/structure data" (the second submit button):

<form action="demo_post_enctype.asp" method="post">
  First name: <input type="text" name="fname"><br>
  <input type="submit" value="Submit">
  <input type="submit" formenctype="multipart/structure data"
  value="Submit as Multipart/structure data">
</form>
Try it Yourself »

The formmethod Attribute

The formmethod quality characterizes the HTTP strategy for sending structure information to the activity URL.

The formmethod quality supersedes the technique characteristic of the <form> element.

The formmethod quality can be utilized with type="submit" and type="image".

Opera Safari Chrome Firefox Internet Explorer

Example

The second submit catch abrogates the HTTP strategy for the form:

<form action="action_page.php" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
  <input type="submit" formmethod="post" formaction="demo_post.asp"
  value="Submit utilizing POST">
</form>
Try it Yourself »

The formnovalidate Attribute

The novalidate quality is a boolean attribute.

When present, it indicates that the <input> component ought not be approved when submitted.

The formnovalidate quality supersedes the novalidate trait of the <form> element.

The formnovalidate quality can be utilized with type="submit".

Opera Safari Chrome Firefox Internet Explorer

Example

A structure with two submit catches (with and without validation):

<form action="action_page.php">
  Email: <input type="email" name="userid"><br>
  <input type="submit" value="Submit"><br>
  <input type="submit" formnovalidate value="Submit without validation">
</form>
Try it Yourself »

The formtarget Attribute

The formtarget property determines a name or a catchphrase that demonstrates where to show the reaction that is gotten in the wake of presenting the form.

The formtarget property supersedes the objective characteristic of the <form> element.

The formtarget property can be utilized with type="submit" and type="image".

Opera Safari Chrome Firefox Internet Explorer

Example

A structure with two submit catches, with various target windows:

<form action="action_page.php">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit as normal">
  <input type="submit" formtarget="_blank"
  value="Submit to another window">
</form>
Try it Yourself »

The tallness and width Attributes

The tallness and width characteristics determine the stature and width of a <input> element.

The tallness and width characteristics are just utilized with <input type="image">.

Opera Safari Chrome Firefox Internet Explorer

Example

Define an image as the submit button, with height and width attributes:

<input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">
Try it Yourself »

The list Attribute

The list ascribe alludes to a <datalist> component that contains pre-characterized alternatives for a <input> element.

Opera Safari Chrome Firefox Internet Explorer

Example

An <input> component with pre-characterized qualities in a <datalist>:

<input list="browsers">

<datalist id="browsers">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
</datalist>
Try it Yourself »

The min and max Attributes

The min and max traits indicate the base and greatest incentive for a <input> element.

The min and max traits work with the accompanying info types: number, extend, date, datetime, datetime-neighborhood, month, time and week.

Opera Safari Chrome Firefox Internet Explorer

Example

<input> components with min and max values:

Enter a date before 1980-01-01:
<input type="date" name="bday" max="1979-12-31">

Enter a date after 2000-01-01:
<input type="date" name="bday" min="2000-01-02">

Amount (somewhere in the range of 1 and 5):
<input type="number" name="quantity" min="1" max="5">
Try it Yourself »

The numerous Attribute

The numerous trait is a boolean attribute.

When present, it indicates that the client is permitted to enter more than one incentive in the <input> element.

The various characteristic works with the accompanying info types: email, and file.

Opera Safari Chrome Firefox Internet Explorer

Example

A record transfer field that acknowledges numerous values:

Select pictures: <input type="file" name="img" multiple>
Try it Yourself »

The design Attribute

The design quality indicates a customary articulation that the <input> component's esteem is checked against.

The design trait works with the accompanying info types: content, look, url, tel, email, and password.

Tip: Use the worldwide title credit to depict the example to help the user.

Tip: Learn progressively about regular expressions in our JavaScript tutorial.

Opera Safari Chrome Firefox Internet Explorer

Example

An input field that can contain just three letters (no numbers or exceptional characters):

Nation code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter nation code">
Try it Yourself »

The placeholder Attribute

The placeholder property indicates a clue that portrays the normal estimation of an information field (an example esteem or a short depiction of the format).

The clue is shown in the information field before the client enters a value.

The placeholder property works with the accompanying information types: content, seek, url, tel, email, and password.

Opera Safari Chrome Firefox Internet Explorer

Example

An input field with a placeholder text:

<input type="text" name="fname" placeholder="First name">
Try it Yourself »

The required Attribute

The required characteristic is a boolean attribute.

When present, it determines that an information field must be rounded out before presenting the form.

The required property works with the accompanying information types: content, look, url, tel, email, secret phrase, date pickers, number, checkbox, radio, and file.

Opera Safari Chrome Firefox Internet Explorer

Example

A required info field:

Username: <input type="text" name="usrname" required>
Try it Yourself »

The step Attribute

The step quality determines the lawful number interims for a <input> element.

Example: if step="3", legitimate numbers could be - 3, 0, 3, 6, etc.

Tip: The progression quality can be utilized together with the max and min credits to make a scope of lawful values.

The step characteristic works with the accompanying input types: number, extend, date, datetime, datetime-nearby, month, time and week.

Opera Safari Chrome Firefox Internet Explorer

Example

An input field with a predefined lawful number intervals:

<input type="number" name="points" step="3">
Try it Yourself »