javascript thread: Help with using OnKeyPress() to limit text inside a <textarea> box
Ooops.. Sorry...
Remove that "alert(str);" Line from your Script...It will work fine...
Pon.
> -----Original Message-----
> From: Do, Anh [mailto:Anhdo@a...]
> Sent: Tuesday, October 16, 2001 11:09 AM
> To: javascript
> Subject: [javascript] RE: Help with using OnKeyPress() to limit text i
> nsid e a <textarea> box
>
>
> Pon,
>
> I'm not getting this one to work. Every time I type a letter
> a javascript
> window pops up with a blank message.
>
> > -----Original Message-----
> > From: Selvaraj PT [SMTP:PSelvaraj@s...]
> > Sent: Tuesday, October 16, 2001 10:12 AM
> > To: javascript
> > Subject: [javascript] RE: Help with using OnKeyPress()
> to limit text i nsid e a <textarea> box
> >
> > Hi Anh Do,
> >
> > Try this one...Hoipe this helps you...
> >
> > Pon.
> >
> >
> > <HTML>
> > <head>
> > <SCRIPT LANGUAGE=javascript>
> > <!--
> > function CheckLength(Name)
> > {
> > var obj = eval("document.form1." + Name);
> >
> >
> > var str = new String;
> > str = obj.value;
> > alert(str);
> > if(Len(str) > 254)
> > {
> > alert("Please restrict your message to Maximum of 255
> Characters");
> > obj.value = Left(str,Len(str)-1);
> > }
> >
> > }
> >
> > function Left(str, n)
> >
> > {
> > if (n <= 0)
> > return "";
> > else if (n > String(str).length)
> > return str;
> > else
> > return String(str).substring(0,n);
> > }
> >
> > function Len(str)
> >
> > {
> > return String(str).length;
> > }
> >
> >
> > //-->
> > </SCRIPT>
> > </head>
> >
> > <body>
> >
> > <FORM action="" method=POST id=form1 name=form1>
> > Req. Documents/Education:<br>(255 characters max.)
> > <TEXTAREA style="WIDTH: 674px; HEIGHT: 283px"
> name=TEXTAREA1 rows=14 cols=73
> > onKeyPress="CheckLength(this.name);"></TEXTAREA>
> > <TEXTAREA style="WIDTH: 674px; HEIGHT: 283px"
> name=TEXTAREA2 rows=14 cols=73
> > onKeyPress="CheckLength(this.name);"></TEXTAREA>
> > </FORM>
> > </body>
> > </HTML>