[Javascript] Q on interuppting char entry

BEKIM BACAJ trojani2000 at hotmail.com
Sun Apr 13 15:58:35 CDT 2003


you wrote:
>set onkeypress to false?  how will you delete the existing contents so you 
>can reword your sentences to make them short enough to fit?

I say:
simply with "bck space" and/or the "del" key!

than you wrote:
>can you have the form event handler trap onkeydown, then get the id of the
>firing object to determine the maxlength and simply return false if the
>length is reached? (and you're not keying a del/bksp)

than I say:
YES!

>From: "Michael Dougherty" <Michael_Dougherty at PBP.com>
>Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
>To: <javascript at LaTech.edu>
>Subject: RE: [Javascript] Q on interuppting char entry
>Date: Sat, 12 Apr 2003 17:37:47 -0400
>
>set onkeypress to false?  how will you delete the existing contents so you
>can reword your sentences to make them short enough to fit?  Doing that
>would be like making the enabled property false, and making the control
>useless as an input device.
>
>can you have the form event handler trap onkeydown, then get the id of the
>firing object to determine the maxlength and simply return false if the
>length is reached? (and you're not keying a del/bksp)
>
>-----Original Message-----
>From: javascript at LaTech.edu [mailto:javascript at LaTech.edu]
>Sent: Saturday, April 12, 2003 2:09 PM
>To: javascript at latech.edu
>Subject: Re: [Javascript] Q on interuppting char entry
>
>
>I admire your script, but it's to messy for me.
>I vould rather simply set the maxLength var for the text input and then
>retrieve the length from last onkeyup event to se if the maxLength is met,
>and then set the onkeypress to false, -no other character will ocur and
>you
>will get rid of that 'flash' forever.
>
>So, try to return the keypress to false after the char limit is met.
>
>Cheers!
>
>
>
> >>From: "Walter Torres" <walter at torres.ws>
> >>Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
> >>To: "[JavaScript List]" <javascript at LaTech.edu>
> >>Subject: [Javascript] Q on interuppting char entry
> >>Date: Fri, 11 Apr 2003 16:50:41 -0500
> >>
> >>I am trying to create a method that limits the character count in a
> >>TEXTAREA, like MAXLENGTH does in TEXT and PASSWORD.
> >>
> >>What I have works (see below), to a point.
> >>
> >>What it does is allow another character to flash in the box, and then it
> >is
> >>removed.
> >>
> >>Anyone have any idea on how to interrupt this character entry at this
> >>point,
> >>thus no character flash?
> >>
> >>Thanks
> >>
> >>Walter
> >>
> >>=================
> >>
> >>var objTA = [favorite method to get Element Reference]
> >>
> >>objTA.onkeypress = setLimit;
> >>objTA.onkeydown  = setLimit;
> >>objTA.onkeyup    = setLimit;
> >>
> >>function setLimit ( )
> >>{
> >>    // Get name of given TEXTAREA
> >>    var strName = this.id;
> >>
> >>    // What is the limit set at for this TEXTAREA
> >>    var intLimit = new Number ( this.getAttribute("maxlength") );
> >>
> >>    // How many characters do we have yet?
> >>    var intCharRemaing = new Number ( intLimit - this.value.length );
> >>    if ( intCharRemaing < 0 )
> >>    {
> >>       this.value = this.value.substring( 0, intLimit  );
> >>       intCharRemaing = 0;
> >>    }
> >>}
> >>
> >>_______________________________________________
> >>Javascript mailing list
> >>Javascript at LaTech.edu
> >>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>_________________________________________________________________
>Add photos to your messages with MSN 8. Get 2 months FREE*.
>http://join.msn.com/?page=features/featuredemail
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail



More information about the Javascript mailing list