This javascript code sample helps to show the number of characters remaining to be entered in the textbox.
The example is a html page that contains a textarea control and a text control. The former is used for user input and the other display number of remaining characters that could be enetered. This value is computed dynamically at the client side by the javascript function given below.
<html>
<body> <script language="JavaScript"> function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) field.value =field.value.substring(0, maxlimit); else countfield.value = maxlimit - field.value.length; } </script>
<form id="form1" method="post"> <textarea name="message" cols="25" rows="4" wrap="PHYSICAL" id="message" onkeydown="textCounter(this.form.message, this.form.remLen,50);" onkeyup="textCounter(this.form.message, this.form.remLen,50); "></textarea> <input name="remLen" type="text" id="remLen" value="50" size="3" maxlength="3" readonly /> </form> </body> </html>
|
No responses found. Be the first to respond and make money from revenue sharing program.
|