javascript:keysuppress(event)

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

    javascript:keysuppress(event)

    How can I make the following code run only when the cursor is in one
    text box and not in another?


    <body onkeypress="jav ascript:keysupp ress(event)"


    function keysuppress(e)
    {
    if (e.type=="keypr ess" && e.keyCode=="13" )
    {
    event.returnVal ue=false
    }
    }

    This would be for I.E. 5.5 and later.



  • Ivo

    #2
    Re: javascript:keys uppress(event)

    "Marcia Gulesian" wrote[color=blue]
    > How can I make the following code run only when the cursor is in one
    > text box and not in another? This would be for I.E. 5.5 and later.
    >
    > <body onkeypress="jav ascript:keysupp ress(event)"
    >
    > function keysuppress(e)
    > {
    > if (e.type=="keypr ess" && e.keyCode=="13" )
    > {
    > event.returnVal ue=false
    > }
    > }[/color]

    Set the handler on the textbox and not on the body element. And remove the
    "javascript :" bit. That would be the quickest, I think. Or identify your
    textboxes and test for an id in the function before deciding on a return
    value.
    HTH
    Ivo


    Comment

    • Marcia Gulesian

      #3
      Re: javascript:keys uppress(event)

      Ivo,

      How exactly do I identify my textboxes and test for an id in the function ?

      Thanks,

      Marcia

      Ivo wrote:
      [color=blue]
      > "Marcia Gulesian" wrote[color=green]
      > > How can I make the following code run only when the cursor is in one
      > > text box and not in another? This would be for I.E. 5.5 and later.
      > >
      > > <body onkeypress="jav ascript:keysupp ress(event)"
      > >
      > > function keysuppress(e)
      > > {
      > > if (e.type=="keypr ess" && e.keyCode=="13" )
      > > {
      > > event.returnVal ue=false
      > > }
      > > }[/color]
      >
      > Set the handler on the textbox and not on the body element. And remove the
      > "javascript :" bit. That would be the quickest, I think. Or identify your
      > textboxes and test for an id in the function before deciding on a return
      > value.
      > HTH
      > Ivo[/color]

      Comment

      • Marcia Gulesian

        #4
        Re: javascript:keys uppress(event)

        I got it:

        document.active Element.getAttr ibute("name")



        Marcia Gulesian wrote:
        [color=blue]
        > Ivo,
        >
        > How exactly do I identify my textboxes and test for an id in the function ?
        >
        > Thanks,
        >
        > Marcia
        >
        > Ivo wrote:
        >[color=green]
        > > "Marcia Gulesian" wrote[color=darkred]
        > > > How can I make the following code run only when the cursor is in one
        > > > text box and not in another? This would be for I.E. 5.5 and later.
        > > >
        > > > <body onkeypress="jav ascript:keysupp ress(event)"
        > > >
        > > > function keysuppress(e)
        > > > {
        > > > if (e.type=="keypr ess" && e.keyCode=="13" )
        > > > {
        > > > event.returnVal ue=false
        > > > }
        > > > }[/color]
        > >
        > > Set the handler on the textbox and not on the body element. And remove the
        > > "javascript :" bit. That would be the quickest, I think. Or identify your
        > > textboxes and test for an id in the function before deciding on a return
        > > value.
        > > HTH
        > > Ivo[/color][/color]

        Comment

        Working...