HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Input Text Object : Get the maximum number of characters allowed in a specific text field
The maxLength property sets or returns the value of the maxlength attribute of a text field.
The maxLength attribute specifies the maximum number of characters allowed in a text field.
Property | |||||
---|---|---|---|---|---|
maxLength | Yes | Yes | Yes | Yes | Yes |
Return the maxLength property:
Set the maxLength property:
Value | Description |
---|---|
number | Specifies the maximum number of characters allowed in the text field |
Return Value: | A Number, representing the maximum number of characters allowed in the text field |
---|
Set the maximum number of characters allowed in a text field:
document.getElementById("myText").maxLength = "4";
Jump to the next text field when a field's maxlength has been reached:
if (y.length == x.maxLength) {
var next = x.tabIndex;
if (next < document.getElementById("myForm").length) {
document.getElementById("myForm").elements[next].focus();
}
}
HTML reference: HTML <input> maxlength attribute
❮ Input Text Object