@Paul_JrFeb 23.2004 — #Something like this? [size=1] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@Paul_JrFeb 24.2004 — #<textarea> doesn't support the maxlength attribute, that's why it won't work. Unfortunately, you'll have to talk to someone else about this, as it's beyond my muddling scope.
I'll see what I can dig up, but you might want to PM Fredmv, or Olerag, or someone JS inclined.
@Paul_JrFeb 24.2004 — #Here, try this. It's kinda smushed together, and you have to specifiy the max length you want, plus 1. So for you it would be 201. [size=1] <script type="text/javascript"> //<![CDATA[ function check(Obj, Objmax) { var maxnum = Obj.value.length; if(Obj.value.length >= Objmax) { alert("Character limit reached."); Obj.value = Obj.value.slice(0, maxnum); } } //]]> </script> ... ... ... <form action="#"> <div> <label for="username">Username: <br /> <textarea id="username" maxlength="2" cols="60" rows="10" onkeydown="check(this, '201');"></textarea> </label> </div> </form> [/size] I'm quite sure there's a better way, but that seems to work.
@Paul_JrFeb 25.2004 — #[i]Originally posted by weee [/i]
[B]it's not good as the other one you showed me.
Thanks man [/B][/QUOTE] Explain?
The other one was technically better, yes, because the character limit was specified using the [FONT=courier new]maxlength[/FONT] atrribute. So, even with JS disabled, the user is only allowed to type in 200 characters -- they just don't get the alert. But since [FONT=courier new]<textarea></textarea>[/FONT] doesn't support that attribute, that affect had to be emulated with JS, therefore users without JS will be able to type in as many characters as they so desire.
Actually, you don't need to specify the limit you want plus one. :o