You are here: Reference > JavaScript > client-side > HTML DOM > properties > textLength (input, textarea)
textLength property (input, textarea)
5 | ||||
Returns the length of the text in a form control.
For a cross-browser solution, use the value.length property instead.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
Integer that retrieves the length of the text in the current element.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the textLength property:
|
||||
<head> <script type="text/javascript"> function GetLengthOfText () { var input = document.getElementById ("input"); alert (input.textLength); } </script> </head> <body> <button onclick="GetLengthOfText ();">Get the length of following text!</button> <input id="input" type="text" value="123456789" /> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
User Contributed Comments