Jump to content

Text decrement


Dr_Jae

Recommended Posts

I am doing a project and I am required to show characters available as the user is typing in the textarea.eg. they have a maximum of 1000 characters for the textarea, as the user types the value in the "title of the textarea" decreases until the user cannot type anymore once the remaining character reaches 0.Please help. Thank you

Link to comment
Share on other sites

Sorted :)

<head><script><!-- Beginfunction textCounter(field, countfield, maxlimit) {if (field.value.length > maxlimit) // if too long...trim it!field.value = field.value.substring(0, maxlimit);// otherwise, update 'characters left' counterelse countfield.value = maxlimit - field.value.length;}// End --></script></head><body><center><form>( You may enter up to 1000 characters. )<br /><textarea name="message" wrap="physical" cols="28" rows="4" onKeyDown="textCounter(this.form.message,this.form.remLen,1000);" onKeyUp="textCounter(this.form.message,this.form.remLen,1000);"></textarea><br /><input readonly type="text" name="remLen" size="3" maxlength="3" value="1000">characters left</form><body>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...