Keypress event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yzzzzz

    Keypress event

    Hi,

    <input type="text" onkeypress="ale rt(this.value)" >

    This doesn't work, it is always 1 character missing because the event
    triggers *before* the character is inserted into the text box. How can I
    get the entire string, including the last character?
    (only needs to work with Mozilla or NN7)

    Thanks.

  • Evertjan.

    #2
    Re: Keypress event

    yzzzzz wrote on 13 jul 2003 in comp.lang.javas cript:[color=blue]
    > <input type="text" onkeypress="ale rt(this.value)" >
    >
    > This doesn't work, it is always 1 character missing because the event
    > triggers *before* the character is inserted into the text box. How can I
    > get the entire string, including the last character?
    > (only needs to work with Mozilla or NN7)[/color]

    onkeyup= ?


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • yzzzzz

      #3
      Re: Keypress event

      Scripsit "Evertjan." :
      [color=blue]
      > yzzzzz wrote on 13 jul 2003 in comp.lang.javas cript:
      >[color=green]
      >><input type="text" onkeypress="ale rt(this.value)" >
      >>
      >>This doesn't work, it is always 1 character missing because the event
      >>triggers *before* the character is inserted into the text box. How can I
      >>get the entire string, including the last character?
      >>(only needs to work with Mozilla or NN7)[/color]
      >
      > onkeyup= ?[/color]

      No!!
      I think the answer is something like onchange, but that only gets
      triggered onblur in Mozilla...


      Comment

      • Grant Wagner

        #4
        Re: Keypress event

        yzzzzz wrote:
        [color=blue]
        > Scripsit "Evertjan." :
        >[color=green]
        > > yzzzzz wrote on 13 jul 2003 in comp.lang.javas cript:
        > >[color=darkred]
        > >><input type="text" onkeypress="ale rt(this.value)" >
        > >>
        > >>This doesn't work, it is always 1 character missing because the event
        > >>triggers *before* the character is inserted into the text box. How can I
        > >>get the entire string, including the last character?
        > >>(only needs to work with Mozilla or NN7)[/color]
        > >
        > > onkeyup= ?[/color]
        >
        > No!!
        > I think the answer is something like onchange, but that only gets
        > triggered onblur in Mozilla...[/color]

        What do you mean, no?

        <form name="myForm">
        <input type="text" name="test" onkeyup="alert( this.value);" />
        </form>

        Tested and alerts the entire content of the input each time a key is released
        in IE6SP1, Mozilla 1.5a, Netscape 4.78 and Opera 7.11.

        Note that in Mozilla, the backspace key causes a keyup event, but not in IE,
        so when the user backspaces in the input, you won't know about the content of
        the input until they press another character or tab out (at which point you
        could test the content in the onblur event).

        --
        | Grant Wagner <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * Internet Explorer DOM Reference available at:
        *
        Gain technical skills through documentation and training, earn certifications and connect with the community


        * Netscape 6/7 DOM Reference available at:
        * http://www.mozilla.org/docs/dom/domref/
        * Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
        * http://www.mozilla.org/docs/web-deve...upgrade_2.html


        Comment

        • Evertjan.

          #5
          Re: Keypress event

          Grant Wagner wrote on 14 jul 2003 in comp.lang.javas cript:
          [color=blue]
          > yzzzzz wrote:
          >[color=green]
          >> Scripsit "Evertjan." :
          >>[color=darkred]
          >> > yzzzzz wrote on 13 jul 2003 in comp.lang.javas cript:
          >> >
          >> >><input type="text" onkeypress="ale rt(this.value)" >
          >> >>
          >> >>This doesn't work, it is always 1 character missing because the
          >> >>event triggers *before* the character is inserted into the text
          >> >>box. How can I get the entire string, including the last character?
          >> >>(only needs to work with Mozilla or NN7)
          >> >
          >> > onkeyup= ?[/color]
          >>
          >> No!!
          >> I think the answer is something like onchange, but that only gets
          >> triggered onblur in Mozilla...[/color]
          >
          > What do you mean, no?
          >
          > <form name="myForm">
          > <input type="text" name="test" onkeyup="alert( this.value);" />
          > </form>
          >
          > Tested and alerts the entire content of the input each time a key is
          > released in IE6SP1, Mozilla 1.5a, Netscape 4.78 and Opera 7.11.
          >[/color]

          Thanks. I usually do not follow up those unsubstanciated "no"s,
          for who knows ;-)

          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          Working...