Limit the length of characters and display it on the description box!

B

Blink70v

Guest
Good morning.

I change phpmyadmin on line description varchar 255 to text 500!
I want to display the number of characters remaining in the description.

I have integrated in wrapper :

PHP:
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
</script>
And in the join_form.html
I have testing to integrat this code :
HTML:
<form name="myform">
<textarea name="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,100);"
onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,100);">
</textarea><br>
<font size="1">(Maximum characters: 100)<br>
You have <input readonly type="text" name="countdown" size="3" value="100"> characters left.</font>
</form>
I changes the HTML part on :
HTML:
<textarea name="description" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,500);"
onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,500);">
id="join_description">{$description}</textarea><br>
<font size="1">(Maximum characters: 500)<br>
You have <input readonly type="text" name="countdown" size="3" value="500"> characters left.</font>
But I did not count the caracteres !
 

Basti

Administrator
Staff member
Change the instances of "limitedtextarea" to "description" and it should work
 
B

Blink70v

Guest
I have already tested :

HTML:
<textarea name="description" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,500);"
onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,500);">
id="join_description">{$description}</textarea><br>
<font size="1">(Maximum characters: 500)<br>
You have <input readonly type="text" name="countdown" size="3" value="500"> characters left.</font>
 
B

Blink70v

Guest
ah

<textarea name="description" onKeyDown="limitText(this.form.description,this.form.countdown,500);"
onKeyUp="limitText(this.form.description,this.form.countdown,500);">
id="join_description">{$description}</textarea><br>
<font size="1">(Maximum characters: 500)<br>
You have <input readonly type="text" name="countdown" size="3" value="500"> characters left.</font>
 
Top