This will help you. Below is a tutorial - a demo is below:
Application:
<input name="text" onKeyDown="CountLeft(this.form.text, this.form.left,50);"
onKeyUp="CountLeft(this.form.text,this.form.left,50);">
JavaScript:
<SCRIPT LANGUAGE="JavaScript">
function CountLeft(field, count, max)
{
if (field.value.length > max)
field.value = field.value.substring(0, max);
else
count.value = max - field.value.length;
}
</SCRIPT>
Demo loan at www.reconn.us
Hope this helps.
source
share