TEXT OnChange

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

    #1

    TEXT OnChange

    I'd like to fire a JS function from the Onchange event of a Text edit.
    Unfortunately it doesn't fire when I hit any key, but only when leaving the
    control. I've tried with OnKeyup, and it works, but it isn't compatible with
    NS6.

    Please any advice ?

    Best regards.

    Bob


  • kaeli

    #2
    Re: TEXT OnChange

    In article <4146c1e8$0$705 $5402220f@news. sunrise.ch>, bedford1
    @YouKnowWhatToD oHerehotmail.co m enlightened us with...[color=blue]
    > I'd like to fire a JS function from the Onchange event of a Text edit.
    > Unfortunately it doesn't fire when I hit any key, but only when leaving the
    > control. I've tried with OnKeyup, and it works, but it isn't compatible with
    > NS6.
    >[/color]

    No, onchange doesn't fire unless focus leaves the element.

    Try onkeypress, depending on what you're trying to accomplish. Sometimes it's
    a fine substitute, sometimes it isn't.

    --
    --
    ~kaeli~
    The man who fell into an upholstery machine is fully
    recovered.



    Comment

    • Bob Bedford

      #3
      Re: TEXT OnChange

      OnKeyPress is the same than OnKeyUp, it doesn't work with NS6
      I will add an additional window.

      Thanks

      Bob

      "kaeli" <tiny_one@NOSPA M.comcast.net> a écrit dans le message de
      news:MPG.1bb0b0 eb7caa28bc98a12 3@nntp.lucent.c om...[color=blue]
      > In article <4146c1e8$0$705 $5402220f@news. sunrise.ch>, bedford1
      > @YouKnowWhatToD oHerehotmail.co m enlightened us with...[color=green]
      > > I'd like to fire a JS function from the Onchange event of a Text edit.
      > > Unfortunately it doesn't fire when I hit any key, but only when leaving[/color][/color]
      the[color=blue][color=green]
      > > control. I've tried with OnKeyup, and it works, but it isn't compatible[/color][/color]
      with[color=blue][color=green]
      > > NS6.
      > >[/color]
      >
      > No, onchange doesn't fire unless focus leaves the element.
      >
      > Try onkeypress, depending on what you're trying to accomplish. Sometimes[/color]
      it's[color=blue]
      > a fine substitute, sometimes it isn't.
      >
      > --
      > --
      > ~kaeli~
      > The man who fell into an upholstery machine is fully
      > recovered.
      > http://www.ipwebdesign.net/wildAtHeart
      > http://www.ipwebdesign.net/kaelisSpace
      >
      >[/color]


      Comment

      • Ben Measures

        #4
        Re: TEXT OnChange

        Bob Bedford wrote:[color=blue]
        > OnKeyPress is the same than OnKeyUp,[/color]

        It's not quite the same:
        http://www.w3.org/TR/html4/interact/...def-onkeypress
        [color=blue]
        > it doesn't work with NS6[/color]

        Since they are both described in the w3.org HTML 4.01 standard, why not
        just use it and advise users to get a compliant browser (such as NS7)?

        --
        Ben M.

        Comment

        • Andrew Thompson

          #5
          Re: TEXT OnChange

          On Tue, 14 Sep 2004 17:11:33 GMT, Ben Measures wrote:
          [color=blue][color=green]
          >> it doesn't work with NS6[/color]
          >
          > Since they are both described in the w3.org HTML 4.01 standard, why not
          > just use it and advise users...[/color]

          Advise users? If some web-site author
          'advised' me to get a decent browser
          I'd advise them to get a working site
          (assuming imparting that advice was quicker
          than the 'back' button, which, since it's
          not, leave's the site in the lurch).

          Who cares? ( I mean, ..besides the site author. )

          --
          Andrew Thompson
          http://www.PhySci.org/ Open-source software suite
          http://www.PhySci.org/codes/ Web & IT Help
          http://www.1point1C.org/ Science & Technology

          Comment

          • Ben Measures

            #6
            Re: TEXT OnChange

            Andrew Thompson wrote:[color=blue]
            > Ben Measures wrote:
            >[color=green][color=darkred]
            >>>it doesn't work with NS6[/color]
            >>
            >>Since they are both described in the w3.org HTML 4.01 standard, why not
            >>just use it and advise users to get a compliant browser?[/color]
            >
            > Advise users? If some web-site author
            > 'advised' me to get a decent browser
            > I'd advise them to get a working site[/color]

            All an author can do to help interoperabilit y is to code to the w3.org
            standards and add workarounds for broken browsers. In the case of onkey*
            there is no workaround - if a browser doesn't support it no workaround
            can be written to emulate it.

            So all the OP can do now is use this attribute (as specified in the
            w3.org standards) and advise users to use a standards-compliant browser.
            Since there are no workarounds he is fully justified in doing this.

            If even the features of the specifications given by w3.org are taboo
            then what hope is there for the progression of the www?

            --
            Ben M.

            Comment

            • kaeli

              #7
              Re: TEXT OnChange

              In article <9DF1d.455$VC3. 5391491@news-text.cableinet. net>,
              saint_abroadrem ove@removehotma il.com enlightened us with...[color=blue]
              > Bob Bedford wrote:[color=green]
              > > OnKeyPress is the same than OnKeyUp,[/color]
              >
              > It's not quite the same:
              > http://www.w3.org/TR/html4/interact/...def-onkeypress
              >[color=green]
              > > it doesn't work with NS6[/color]
              >
              > Since they are both described in the w3.org HTML 4.01 standard, why not
              > just use it and advise users to get a compliant browser (such as NS7)?
              >
              >[/color]

              Is that true that NN6 doesn't support that, but NN7 does?

              Oh, my bad.
              I thought NN6 was fully html 4.01 compliant.
              I learn something new daily.


              --
              --
              ~kaeli~
              You can't have everything. Where would you put it?



              Comment

              • Richard Cornford

                #8
                Re: TEXT OnChange

                Andrew Thompson wrote:[color=blue]
                > Ben Measures wrote:[color=green][color=darkred]
                >>> it doesn't work with NS6[/color]
                >>
                >> Since they are both described in the w3.org HTML 4.01
                >> standard, why not just use it and advise users...[/color]
                >
                > Advise users? If some web-site author
                > 'advised' me to get a decent browser
                > I'd advise them to get a working site
                > (assuming imparting that advice was quicker
                > than the 'back' button, which, since it's
                > not, leave's the site in the lurch).
                >
                > Who cares? ( I mean, ..besides the site author. )[/color]

                With no code presented to demonstrate that there even is a problem with
                Netscape 6, rather than an authoring mistake, it would be premature to
                be bothering the user about their choice of browser.

                Richard.


                Comment

                • Ben Measures

                  #9
                  Re: TEXT OnChange

                  kaeli wrote:[color=blue]
                  >
                  > I thought NN6 was fully html 4.01 compliant.
                  > I learn something new daily.[/color]

                  AOL/Netscape prematurely released NN6. It was based on pre-1.0 Mozilla
                  (iirc it was based on M18, pre-0.6). Inevitably there were bugs,
                  incompatibiliti es and general brokeness. It should never have happened.

                  It was only when NN7 was released (based on post-1.0 Mozilla code) that
                  it became anywhere near the standards-compliant browser that it is today.

                  --
                  Ben M.

                  Comment

                  • Grant Wagner

                    #10
                    Re: TEXT OnChange

                    onkeypress should work with Netscape 6. I am almost certain I used it
                    successfully. However, if you are trying to add it programmaticall y:

                    document.forms['myForm'].elements['myElement'].onkeypress = myHandler;

                    Then you need the following code in your <form>

                    <input type="text" name="myElement " value="" onkeypress="">

                    The empty onkeypress="" is _not_ optional in some early versions of Gecko-based
                    browsers if you are trying to add an event handler programmaticall y. These
                    early versions of Gecko-based browsers had a problem where if event handlers
                    were not registered when the HTML was parsed, your event would be attached
                    _after_ the standard application-level event handler.

                    The following code snippet should work just fine in Netscape 6 (I tested it in
                    Mozilla 1.0 and it generated the correct alert() on each keypress):

                    <body onload="
                    document.forms['myForm'].elements['myElement'].onkeypress =
                    function (e) {
                    alert('You pressed ' + (e && e.which ? e.which : event.keyCode)) ;
                    }
                    ">
                    <form name="myForm">
                    <input type="text" name="myElement " value="" onkeypress="">
                    </form>
                    </body>

                    Bob Bedford wrote:
                    [color=blue]
                    > OnKeyPress is the same than OnKeyUp, it doesn't work with NS6
                    > I will add an additional window.
                    >
                    > Thanks
                    >
                    > Bob
                    >
                    > "kaeli" <tiny_one@NOSPA M.comcast.net> a écrit dans le message de
                    > news:MPG.1bb0b0 eb7caa28bc98a12 3@nntp.lucent.c om...[color=green]
                    > > In article <4146c1e8$0$705 $5402220f@news. sunrise.ch>, bedford1
                    > > @YouKnowWhatToD oHerehotmail.co m enlightened us with...[color=darkred]
                    > > > I'd like to fire a JS function from the Onchange event of a Text edit.
                    > > > Unfortunately it doesn't fire when I hit any key, but only when leaving[/color][/color]
                    > the[color=green][color=darkred]
                    > > > control. I've tried with OnKeyup, and it works, but it isn't compatible[/color][/color]
                    > with[color=green][color=darkred]
                    > > > NS6.
                    > > >[/color]
                    > >
                    > > No, onchange doesn't fire unless focus leaves the element.
                    > >
                    > > Try onkeypress, depending on what you're trying to accomplish. Sometimes[/color]
                    > it's[color=green]
                    > > a fine substitute, sometimes it isn't.[/color][/color]

                    --
                    Grant Wagner <gwagner@agrico reunited.com>
                    comp.lang.javas cript FAQ - http://jibbering.com/faq


                    Comment

                    • Ben Measures

                      #11
                      Re: TEXT OnChange

                      Grant Wagner wrote:[color=blue]
                      > onkeypress should work with Netscape 6. I am almost certain I used it
                      > successfully.[/color]

                      You seem to be right -

                      lists NN6 as supporting the HTML onkey*.

                      --
                      Ben M.

                      Comment

                      • Michael Winter

                        #12
                        Re: TEXT OnChange

                        On Tue, 14 Sep 2004 12:03:22 +0200, Bob Bedford
                        <bedford1@YouKn owWhatToDoHereh otmail.com> wrote:
                        [color=blue]
                        > I'd like to fire a JS function from the Onchange event of a Text edit.
                        > Unfortunately it doesn't fire when I hit any key, but only when leaving
                        > the control.[/color]

                        That's exactly what it's supposed to do. If the value of a control changes
                        between entering and exiting the control, a change event is fired.
                        [color=blue]
                        > I've tried with OnKeyup, and it works, but it isn't compatible with NS6.
                        >
                        > Please any advice ?[/color]

                        Validate using the change event. If you're trying to stop certain
                        characters being entered, it won't be reliable. Someone could paste a
                        value in and you won't catch the prohibited characters.

                        Mike

                        --
                        Michael Winter
                        Replace ".invalid" with ".uk" to reply by e-mail.

                        Comment

                        Working...