1. 01. Incoming
  2. 02. Hifi
  3. 03. Lofi
  4. 04. The Lab
  5. 05. Tags

frequency decoder

Unobtrusive textarea maxlength functionality

Posted Saturday September 10, 2005

frequency decoder

A simple unobtrusive javascript that enables textarea input to be assigned a maximum character length

Whilst not the most racy of scripts, it may come in handy for web developers looking for a way to mimic the input tags built-in “maxlength” attribute.

Useful as a preliminary character length check before inserting user input into a fixed-width database column (although server side checking should always be done – but you know that already!).

Tested in Internet Explorer 5+ (Windows), Firefox, Mozilla and Opera.

View the textarea maxlength demo.

Tags: maxlength, textarea

Previous Comments ~

Chris · http://www.csb7.com
#1 · Sunday January 29, 2006
I was about to paste a bug report about pasting text into the textarea, but I now see you are handling that onblur(). Plus you are already taking charage returns into account. Very well done. I’ll be visiting this site more often now that I’ve found you (via a comment on http://cf-bill.blogspot.com)
frequency decoder
#2 · Tuesday January 31, 2006
Hi Chris,

Yep, I handle the onblur event in anything but Internet Explorer (which has a proprietary onpaste event that, in this case, is better than using onblur).

Actually, I’ve just noticed a bug in my code… well, not a bug as such but… we should really be removing the onblur event for Internet Explorer as we use it’s proprietary onpaste event.

Et voila, I’ve altered the code to take this into consideration.

Thanks for the interest,

Brian.

P.S. The site is currently falling apart – I shall be redesigning soonish though so, please forgive any crazy CSS/whitespace badness you may encounter.
Simon
#3 · Monday April 10, 2006

Pasting something removes all text after the pasted text (IE 6.0). Try again…

frequency decoder
#4 · Monday April 10, 2006

@ Simon: Fixed.

Lucas Williams · http://www.beyondthepixel.com
#5 · Wednesday December 13, 2006

Is there a quick easy way to add a character counter to this script :) ?

Comments are currently closed for this article but feel free to email me with your input - I’d love to hear it.

Popular Frequencies

  • Unobtrusive Table Sort Script (revi…
    Saturday September 16, 2006
  • Unobtrusive Date-Picker Widget Upda…
    Monday October 02, 2006
  • Unobtrusive Table Sort Script
    Friday November 18, 2005
  • Unobtrusive Date-Picker Widgit
    Friday October 14, 2005
  • Unobtrusive Table Actions Script
    Thursday November 15, 2007

Google Ads

All articles