Dr_Jae Posted February 17, 2006 Share Posted February 17, 2006 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 More sharing options...
Pollux Posted February 17, 2006 Share Posted February 17, 2006 Without actually writing it for you, a start would be to use an onkeypress event which calls a function which does your processing. Link to comment Share on other sites More sharing options...
scott100 Posted February 17, 2006 Share Posted February 17, 2006 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 More sharing options...
Dr_Jae Posted February 24, 2006 Author Share Posted February 24, 2006 your a life saver... Thanks a million Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now