Maxlength

The ‘maxlength’ attribute is used to limit the number of characters a user may enter into a text field. For example, a text field that expects a year, may be limited to maxlength="4" characters.

HTML
<p>
  Birth Year:
  <input type="text" name="name" id="test-date" maxlength="4" />
</p>

Please Enter:

Birth Year:

Net ID:

Password:

Comments or Concerns:

NOTE: Type in the date box above. You will find (at least in most browsers) that you cannot type more than 4 characters.