Are your readers writing their own version of War and Peace in your comments?
We really hope you aren't getting comments like this...but it's possible
Comments can be useful, but if readers are sending inappropriately long comments, limiting them to a set number of characters can help encourage them to shorten things up.
Adapt the script below to limit the total number of characters for the comments and show commenters how many characters they have remaining. The end-result looks like this:
To add this character limit to your comments:
- Go to Customize > Style (HTML & CSS).
- In the Customize HTML, CSS, and JS section, select Custom HTML.
- Select Article from the Select HTML section to edit dropdown.
- Copy the script below and paste it into the bottom of the Custom HTML:
<script> $(function(){ //Set character limit on comments var maxchars = '300'; //Change this number to change the character limit $('.hg-comment-post textarea').before('<div class="text-right"><span id="remain">'+maxchars+'</span> characters remaining</div>'); $('.hg-comment-post textarea').keyup(function () { var tlength = $(this).val().length; $(this).val($(this).val().substring(0, maxchars)); var tlength = $(this).val().length; remain = maxchars - parseInt(tlength); $('#remain').text(remain); }); }); </script>
- In row 4, change the number set for var maxchars to the number of characters you want to use. Be sure it stays in 'single quotes'.
- Save.
Readers are shown a statement like "140 characters remaining" which updates as they type. They won't be able to type more than the allowed characters. It even works with copy and paste.
Check it out
We've added the code to this page so you can see it in action.