HTML <input> Tag with the 'maxlength' Attribute
<form name="myForm" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
<input maxlength="5" name="myField">
<button>Submit</button>
</form>
The above example demonstrates usage of the <input>
element with the maxlength
attribute.
The maxlength
attribute allows you to restrict the length of the value that the user can input. Specifically, it allows you to specify a maximum number of characters that the user can input.
You can also use minlength
to specify a minimum length.