JS statistics text box string, and real-time display the remaining characters, effect such as this blog comment word limit effect, share here, in the upload text works, I believe this will have a good effect on the user experience.
The code is relatively simple:
JavaScript code 01
The code is as follows |
Copy Code |
. <script language= "JavaScript" > <!--// function textcounter (field, Countfield, Maxlimit) { Define functions, pass in 3 parameters, respectively, the name of the form area, the form field element name, character limit; if (Field.value.length > Maxlimit) If the number of characters in the element area is greater than the maximum number of characters, truncated by the largest character; Field.value = field.value.substring (0, Maxlimit); Else Displays the remaining number of characters in the Register text box; Countfield.value = Maxlimit-field.value.length; } --> </script> |
Full instance
The code is as follows |
Copy Code |
<table border= "0" cellpadding= "0" style= "border-style:solid; border-width:1px; padding:1px; Border-collapse:collapse "bordercolor=" #CCCCCC "width=" 100% "height=" 184 ">
<form action= "return1_w.php" method= "POST" target= "_blank" style= "margin:0px"; padding:0px; " > <tr> <TD width= "height=" ><div align= "right" style= "font-size:12px" > Username:</div></td> <TD height= "> " <input readonly= "readonly" type= "text" name= "Remlen" size= "4" maxlength= "3" value= "he"/> Characters (you can give me comments or suggestions here, oh ^_^) </td> </tr> <tr> <TD width= "height=" ><script language= "JavaScript" > <!--// function textcounter (field, Countfield, Maxlimit) { Define functions, pass in 3 parameters, respectively, the name of the form area, the form field element name, character limit; if (Field.value.length > Maxlimit) If the number of characters in the element area is greater than the maximum number of characters, truncated by the largest character; Field.value = field.value.substring (0, Maxlimit); Else Displays the remaining number of characters in the Register text box; Countfield.value = Maxlimit-field.value.length; } --> </script> <div align= "Right" style= "font-size:12px" > Reply content:</div></td> <TD width= "396" height= "><textarea rows=" "4" name= "Neirong" cols= "onkeydown=" Textcounter ( this.form.neirong,this.form.remlen,150); " Onkeyup= "Textcounter (this.form.neirong,this.form.remlen,150);" > </textarea></td> </tr> <tr> <TD height= "colspan=" 2 "><div align=" center "> <input type= "Submit" value= "release" Name= "HF"/> </div></td> </tr> <tr> <TD colspan= "2" ><table border= "0" cellpadding= "0" cellspacing= "0" style= "border-collapse:collapse" Bordercolor= "#111111" width= "100%" > <tr> <TD width= "100%" height= "1" colspan= "4" ></td> </tr> </table></td> </tr> </form> </table> |