greasemonkey script

30 January, 2006

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

See other posts tagged with general and all posts made in January 2006.


31 January, 2006 at 00:14

the ‘notes’ field also cuts you off at 255. Might want to include that one too.

31 January, 2006 at 12:27

ah really? I didn’t know that. I’ll put a patch in at some point.

01 February, 2006 at 00:41

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.

01 February, 2006 at 10:55

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.