MyBB Community Forums

Full Version: Add characters counter newthread & editpost
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
No matter what I do I can't add characters counter that will count message and subject area!

This is not what I am adding just to post here!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function countit(what){
formcontent=what.form.subject.value
what.form.displaycount.value=formcontent.length
}
</script>
</head>

<body>
<form>
<table style="width: 400px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 200px;">
<textarea name="subject" wrap="virtual" onkeyup="countit(this)"></textarea>
</td>
</tr>
<tr>
<td style="width: 200px;"><div align="right"><input type="text" name="displaycount" size="20" readonly="readonly"></div>
</td>
</tr>
</table>
</form>

</body>
</html>

For some reason form is not detected by JavaScript!
I can't see any terminator in your script, though I've not gone through.

This is as simple as this:

<script type="text/javascript">
jQuery.noConflict();
jQuery("#message_new").keyup(function(){
	var msgLen=jQuery(this).val().length;
	jQuery("#counter").text(" You have entered "+msgLen+".");
});
</script>

If you add a span with id 'counter' somewhere in your page it will show the value.
@effone buddy thanks very much. Could you also please make it check title input field!


Title
Message

Also will it work in editpost template?


I only need your code right?


I can't get it working how to do it?
As in the topic about 24h message bar, you need to add and load jQuery library in headerinclude for effone's solution.

Non-jQuery fixed JS:
<script type="text/javascript">
function countit(what) {
   var formcontent = what.form.subject.value;
   what.form.displaycount.value = formcontent.length;
}
</script>
@effone you are my hero thanks very much for your code +1

D666 man you know exactly what daddy Marcus wants thanks man!
I told you DADDY, to add TERMINATORS in your script :p
Read my first line ...
@effone thanks very much yeah I only had to add ; at the end of each line you know I love you man just that I don't like adding external links to my site!

Listen do you know how to make it work with with message editor in newthread template because I doesn't work with it?