<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "lang=" gb2312 "> <pead> <pead& Gt <title> Code: Use JavaScript to limit textarea input length (For:ie, Firefox ...) </title> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <meta name=" author "content=" Maple Rock, CNLei.y.l@gmail.com "> <meta name=" keywords "content=" t Extarea, input Length "/> <meta name=" description "content=" uses JavaScript to limit textarea input length (For:ie, Firefox ...)/> <st YLE type= "Text/css" media= "all" > body {font-size:14px;} </style> </pead> <body> maxlength=10 <textarea maxlength= "onkeyup=" return Ismaxlen (This) "></textarea> maxlength=20 <textarea maxlength=" onkeyup= "Return to Ismaxlen (this)" ></textarea > <script type= "text/javascript" > Function Ismaxlen (o) {var nmaxlen=O.getattribute? parseint (O.getattribute ("MaxLength")): ""; if (O.getattribute && o.value.length>nmaxlen) {o.value=o.value.substring (0,nmaxlen)}} </script> ; </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]