form unasked submitting

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

    #1

    form unasked submitting

    hi to all!
    how can i prevent the "return / enter" key to submit the current form
    if hit in a text input? i've actually added the code:
    onKeyPress="if( event.KeyCode== 13){doGivenFunc tion();}"
    to make it react the way i'd like (calling a function and not
    submitting the form), but it doesn not work.
    any suggestion?

    thanks in advance for any eventual help
  • Evertjan.

    #2
    Re: form unasked submitting

    Gu wrote on 13 mei 2005 in comp.lang.javas cript:
    [color=blue]
    > hi to all!
    > how can i prevent the "return / enter" key to submit the current form
    > if hit in a text input? i've actually added the code:
    > onKeyPress="if( event.KeyCode== 13){doGivenFunc tion();}"
    > to make it react the way i'd like (calling a function and not
    > submitting the form), but it doesn not work.
    > any suggestion?[/color]


    <input onKeyPress="ret urn !(event.KeyCode ==13)">press</div>


    You will need to cancell the keypress



    [color=blue]
    > thanks in advance for any eventual help
    >[/color]



    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    • Evertjan.

      #3
      Re: form unasked submitting

      Evertjan. wrote on 13 mei 2005 in comp.lang.javas cript:
      [color=blue]
      > Gu wrote on 13 mei 2005 in comp.lang.javas cript:
      >[color=green]
      >> hi to all!
      >> how can i prevent the "return / enter" key to submit the current form
      >> if hit in a text input? i've actually added the code:
      >> onKeyPress="if( event.KeyCode== 13){doGivenFunc tion();}"
      >> to make it react the way i'd like (calling a function and not
      >> submitting the form), but it doesn not work.
      >> any suggestion?[/color]
      >
      >
      > <input onKeyPress="ret urn !(event.KeyCode ==13)">
      >
      > You will need to cancell the keypress[/color]

      Sorry, pressed the "send" button too soon

      KeyCode should be keyCode


      Try this:

      <input onKeyPress="ret urn(event.keyCo de!=13)">

      [color=blue][color=green]
      >> thanks in advance for any eventual help[/color][/color]

      eventual like in event.keyCode? ;-}


      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      • Gu

        #4
        Re: form unasked submitting

        On 13 May 2005 19:09:12 GMT, "Evertjan."
        <exjxw.hannivoo rt@interxnl.net > wrote:

        [color=blue]
        >eventual like in event.keyCode? ;-}[/color]

        LOL

        Comment

        • Gu

          #5
          Re: form unasked submitting

          On 13 May 2005 19:09:12 GMT, "Evertjan."
          <exjxw.hannivoo rt@interxnl.net > wrote:
          [color=blue]
          >Evertjan. wrote on 13 mei 2005 in comp.lang.javas cript:
          >[color=green]
          >> Gu wrote on 13 mei 2005 in comp.lang.javas cript:
          >>[color=darkred]
          >>> hi to all!
          >>> how can i prevent the "return / enter" key to submit the current form
          >>> if hit in a text input? i've actually added the code:
          >>> onKeyPress="if( event.KeyCode== 13){doGivenFunc tion();}"
          >>> to make it react the way i'd like (calling a function and not
          >>> submitting the form), but it doesn not work.
          >>> any suggestion?[/color]
          >>
          >>
          >> <input onKeyPress="ret urn !(event.KeyCode ==13)">
          >>
          >> You will need to cancell the keypress[/color]
          >
          >Sorry, pressed the "send" button too soon
          >
          >KeyCode should be keyCode
          >
          >
          >Try this:
          >
          ><input onKeyPress="ret urn(event.keyCo de!=13)">
          >
          >[color=green][color=darkred]
          >>> thanks in advance for any eventual help[/color][/color]
          >
          >eventual like in event.keyCode? ;-}[/color]


          hmm.. well, you code works, thanks for that, in preventing the form to
          submit, but how can i use it for triggering a function when enter is
          pressed? the current code is:

          onKeyPress="if( event.keyCode== 13){invia();}"

          Comment

          • Evertjan.

            #6
            Re: form unasked submitting

            Gu wrote on 14 mei 2005 in comp.lang.javas cript:
            [color=blue][color=green]
            >>Try this:
            >>
            >><input onKeyPress="ret urn(event.keyCo de!=13)">[color=darkred]
            >>>> thanks in advance for any eventual help[/color]
            >>eventual like in event.keyCode? ;-}[/color]
            >
            > hmm.. well, you code works, thanks for that, in preventing the form to
            > submit, but how can i use it for triggering a function when enter is
            > pressed? the current code is:
            >
            > onKeyPress="if( event.keyCode== 13){invia();}"[/color]

            This has been told zillions of times in this NG,
            and is available in the archive.

            onKeyPress="if( event.keyCode== 13){invia();ret urn false}"

            If you want both the execution of invia()
            and the prevention of submission.

            Try:

            onKeyPress=
            "if(event.keyCo de==13){alert(' You pressed enter');return false}"

            Or

            onKeyPress=
            "if(event.keyCo de==13){return confirm('Do you really want submission?')}"



            --
            Evertjan.
            The Netherlands.
            (Replace all crosses with dots in my emailaddress)

            Comment

            Working...