JavaScript Reference/Javascript Properties/maxLength

Материал из Web эксперт
Перейти к: навигация, поиск

"maxLength" Example

   <source lang="javascript">
   

<html> <body> <input type="password" id="myText"> <script language="JavaScript">

   document.getElementById("myText").maxLength = 10;

</script> </body> </html>


     </source>
   
  


"maxLength" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<input type="password"> <input type="text"> | +----------------+--------------------------------------------------------------+

     </source>
   
  


"maxLength" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Sets the maximum number of characters that can fit into the text field.

Syntax:

document.getElementById("inputID").maxLength = value document.all.inputID.maxLength = value // IE only


     </source>