greasemonkey script

A couple of weeks ago, Tom Coates was moaning about a UI aspect of

I do not understand why’ submission form doesn’t limit the amount of characters that you can input into it. Instead, you’re left to work out later that whatever you’d written had been cut off automatically at a couple of hundred characters to fit into the database. This must be the simplest thing to fix, surely?

Actually, yes, it is. Here’s a Greasemonkey script which limits the description field to 255 characters and displays a character counter after the text box so you can see how many you’ve got left when adding a pithy comment.

Install description

Published by

4 thoughts on “ greasemonkey script”

  1. There’s a very good reason not to cut the content off: some people fill the fields primarily by pasting content from the source page, in which case you often want to paste a lot of source material, then edit it down to something that will fit. And if there’s a hard limit on the form inputs, this is impossible.

    Instead, you want to give the user a counter telling them how many bytes the currently entered content is long. If you’re so inclined, add some additional visual cue like turning the text or a label red or something.

    Note that I purposely talked about bytes here: cuts off at 255 bytes, but uses UTF-8, so 255 bytes < 255 characters if your description contains any character outside of US-ASCII.

  2. Yes, I realised both the reasons for not cutting the text off, and I agree with’ decision, hence you can install this if you like.

    After I’d done it, I did actually think about not limiting the text field, and turning it red if you had over 255 characters – I hadn’t realised they limit to 255 bytes, that’s interesting, I’ve never had to count bytes in JavaScript before.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.