
Use this script to display a real-time indication of your signature limit, and how many characters you have remaining. You will be prevented from entering any more characters once you reach 0. Prosilver and Prosilver-based styles only.
What we’re trying to achieve
As a regular forum user, what really annoys me is breaking the signature character limit…but not being told about until after I’ve spent 5 minutes formatting everything. This script will add a live character counter above the signature text box keeping the user informed of exactly how many characters they have left. Once the user reaches the maximum amount of characters, they won’t be able to enter any more into the text box. Thanks go to Remy Sharp for the jQuery functionality.
Preparation
To complete this tutorial, you’ll need a decent source code editor. You also need to download jquery.maxlength.js by clicking the download button above and extracting the zip file. Then perform the following file copy instructions:
- Copy: siglimit/jquery.maxlength.js to /phpBB/styles/prosilver/template/
The HTML Edits
First of all we need to add the message telling users how many characters they have left. We’ll then add a custom class to the textarea so the jQuery can reference it, and finally we’ll add some inline jQuery to power our counter. But firstly, we need to connect to jQuery and our max length script.
Open: /styles/prosilver/template/overall_header.html
Find:
Below, Add:
<script type="text/javascript" src="{T_TEMPLATE_PATH}/jquery.maxlength.js"></script>
Open: /styles/prosilver/template/posting_editor.html
Find:
Before, Add:
<p><strong>Characters remaining:</strong> <span class="charsLeft error">{L_SIGNATURE_LIMIT}</span></p>
<!-- ENDIF -->
Find:
<textarea <!-- IF S_UCP_ACTION and not S_PRIVMSGS and not S_EDIT_DRAFT -->name="signature" id="signature" style="height: 9em;"<!-- ELSE -->name="message" id="message"<!-- ENDIF --> rows="15" cols="76" tabindex="4" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" class="inputbox">{MESSAGE}{DRAFT_MESSAGE}{SIGNATURE}</textarea>
</div>
Replace with:
<textarea <!-- IF S_UCP_ACTION and not S_PRIVMSGS and not S_EDIT_DRAFT -->name="signature" id="signature" style="height: 9em;"<!-- ELSE -->name="message" id="message"<!-- ENDIF --> rows="15" cols="76" tabindex="4" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onfocus="initInsertions();" class="inputbox<!-- IF $SIG_EDIT eq 1 --> limited<!-- ENDIF -->">{MESSAGE}{DRAFT_MESSAGE}{SIGNATURE}</textarea>
<!-- IF $SIG_EDIT eq 1 --><input type="hidden" name="maxlength" value="{L_SIGNATURE_LIMIT}" /><!-- ENDIF -->
</div>
Find:
Before, Add:
<script type="text/javascript">
$('textarea.limited').maxlength({
'feedback' : '.charsLeft',
'useInput' : true
});
</script>
<!-- ENDIF -->
Some PHP Edits
So you’ve probably noticed I’ve used a template variable {L_SIGNATURE_LIMIT}, which don’t exist by default in phpBB. We’re going to create it here. Doing this allows the script to use the “Maximum Signature Length” value defined in the Administration Control Panel, rather than having to hard-code a character limit value into the template file.
Open: /includes/ucp/ucp_profile.php
Find:
Below, Add:
And that’s about it!
Support / Donations
If you encounter any problems implementing this on your board, support is freely available here. If you’d like to leave me a donation for the time spent testing the script and writing the tutorial you can do so here. And finally if you think I’ve missed something you can let me know here. Marvellous.





10 Responses
Not working…….I use Moxy made by RocketTheme. I’d really like this to..but it’s not working..
is it possible to use this also for posting messages
Very nice addition, I saw this over on FP and have been wanting it for some time now. Thanks.
Was it a topic? Or are they using it in the UCP?
I just remember seeing it back when it was not owned by Fergal, I just looked and it is not there now.
I have install this but if I will set a message in my signature then see I 255 Characters remaining
and if I set a message in my signature then see I also 255 Characters remaining how is that possible ?
and is it possible to make this also for posting message for the normal forum ?
so yes how must I do that ?
Terr0r,
I had a bit of trouble with the code at first to, make sure that you are following everything exactly as it is stated above. I ended up just having a simple mistake when following the tutorial on my part.
This is very good work. You have done a lot of homework on this topic and it certainly shows in the way you have represented your material. I enjoyed this article and appreciate your viewpoints.
It doesn`t work. Shows the same message every time I push any button: «Characters remaining: 255». Pitty.
Hi. Are you able to shoot me an email through the contact page with a link to your board?
Thanks.