/ Published in: JavaScript
use to show how many chars are remaining for an input field.
Expand |
Embed | Plain Text
onload="showRemaining(document.forms['myForm'].elements['myInput']);"> <script type="text/javascript"> function showRemaining(formElement) { var theForm = formElement.form; var remainingDisplay = formElement.name + 'Remaining'; theForm.elements[remainingDisplay].value = formElement.maxLength - formElement.value.length; } </script> <form name="myForm"> <input type="text" name="myInput" maxlength="20" onkeyup="showRemaining(this);"> <input type="text" name="myInputRemaining" size="2" readonly> </form>
You need to login to post a comment.
