ENTER key to submit forms

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

    ENTER key to submit forms

    Hello,

    I want to know what I have to do to make the enter key to submit forms. I
    read in another newsgroup that inserting an html hidden text box made the
    trick, and it actually does, but in my page I have more than one web control
    that have their independient "forms" (in the .NET environment, it makes it
    to be just one). And I need that, if the user is, say, writing the keywords
    to perform a search, the enter key submits this form, but if he is writing
    his username and password to login, the enter key submits this other
    one........

    Does anyone know how to do this?

    Best Regards,

    SC


  • S. Justin Gengo

    #2
    Re: ENTER key to submit forms

    Sandra,

    I've created a javascript component with some commonly used javascripts in
    it. One of them does exactly what you are looking for.

    The component is free, comes with a help file, and the entire projects
    source code is available on my web site: www.aboutfortunate.com. Just click
    on the code library link and then click on the "Javascript " button in the
    menu on the left.

    Even if you don't want to use the entire component the code you need to
    create your own is in the project.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    Free code library at:


    "Out of chaos comes order."
    Nietzche


    "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
    news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hello,
    >
    > I want to know what I have to do to make the enter key to submit forms. I
    > read in another newsgroup that inserting an html hidden text box made the
    > trick, and it actually does, but in my page I have more than one web[/color]
    control[color=blue]
    > that have their independient "forms" (in the .NET environment, it makes it
    > to be just one). And I need that, if the user is, say, writing the[/color]
    keywords[color=blue]
    > to perform a search, the enter key submits this form, but if he is writing
    > his username and password to login, the enter key submits this other
    > one........
    >
    > Does anyone know how to do this?
    >
    > Best Regards,
    >
    > SC
    >
    >[/color]


    Comment

    • Sandra Castellanos

      #3
      Re: ENTER key to submit forms

      Hi,

      Thank you very much for the code, but I still have one problem, and it is
      that .NET is the one that builds the form, and it always gives it the name
      of the page, for example if the page is Default.aspx, the name of the form
      will be FormDefault. These "forms" I have are in web controls, and they are
      included in many different pages. So I can't use the name of the form like
      that.... Is there anything like document.forms( 0).thebutton?

      Thanks again and bye

      SC
      "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
      news:eVhFpQ3sDH A.540@tk2msftng p13.phx.gbl...[color=blue]
      > Sandra,
      >
      > I've created a javascript component with some commonly used javascripts in
      > it. One of them does exactly what you are looking for.
      >
      > The component is free, comes with a help file, and the entire projects
      > source code is available on my web site: www.aboutfortunate.com. Just[/color]
      click[color=blue]
      > on the code library link and then click on the "Javascript " button in the
      > menu on the left.
      >
      > Even if you don't want to use the entire component the code you need to
      > create your own is in the project.
      >
      > --
      > Sincerely,
      >
      > S. Justin Gengo, MCP
      > Web Developer / Programmer
      >
      > Free code library at:
      > www.aboutfortunate.com
      >
      > "Out of chaos comes order."
      > Nietzche
      >
      >
      > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
      > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=green]
      > > Hello,
      > >
      > > I want to know what I have to do to make the enter key to submit forms.[/color][/color]
      I[color=blue][color=green]
      > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
      the[color=blue][color=green]
      > > trick, and it actually does, but in my page I have more than one web[/color]
      > control[color=green]
      > > that have their independient "forms" (in the .NET environment, it makes[/color][/color]
      it[color=blue][color=green]
      > > to be just one). And I need that, if the user is, say, writing the[/color]
      > keywords[color=green]
      > > to perform a search, the enter key submits this form, but if he is[/color][/color]
      writing[color=blue][color=green]
      > > his username and password to login, the enter key submits this other
      > > one........
      > >
      > > Does anyone know how to do this?
      > >
      > > Best Regards,
      > >
      > > SC
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Sandra Castellanos

        #4
        Re: ENTER key to submit forms

        Sorry, ignore the previous message, I was just being stupid.

        SC
        "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
        news:eVhFpQ3sDH A.540@tk2msftng p13.phx.gbl...[color=blue]
        > Sandra,
        >
        > I've created a javascript component with some commonly used javascripts in
        > it. One of them does exactly what you are looking for.
        >
        > The component is free, comes with a help file, and the entire projects
        > source code is available on my web site: www.aboutfortunate.com. Just[/color]
        click[color=blue]
        > on the code library link and then click on the "Javascript " button in the
        > menu on the left.
        >
        > Even if you don't want to use the entire component the code you need to
        > create your own is in the project.
        >
        > --
        > Sincerely,
        >
        > S. Justin Gengo, MCP
        > Web Developer / Programmer
        >
        > Free code library at:
        > www.aboutfortunate.com
        >
        > "Out of chaos comes order."
        > Nietzche
        >
        >
        > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
        > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=green]
        > > Hello,
        > >
        > > I want to know what I have to do to make the enter key to submit forms.[/color][/color]
        I[color=blue][color=green]
        > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
        the[color=blue][color=green]
        > > trick, and it actually does, but in my page I have more than one web[/color]
        > control[color=green]
        > > that have their independient "forms" (in the .NET environment, it makes[/color][/color]
        it[color=blue][color=green]
        > > to be just one). And I need that, if the user is, say, writing the[/color]
        > keywords[color=green]
        > > to perform a search, the enter key submits this form, but if he is[/color][/color]
        writing[color=blue][color=green]
        > > his username and password to login, the enter key submits this other
        > > one........
        > >
        > > Does anyone know how to do this?
        > >
        > > Best Regards,
        > >
        > > SC
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Sandra Castellanos

          #5
          Re: ENTER key to submit forms

          I'm sorry, could you please tell me how to attach this eventhandler to my
          textboxes? I am working with <asp:textbox> . does it work with them?
          Sorry :'(

          SC
          "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
          news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Hello,
          >
          > I want to know what I have to do to make the enter key to submit forms. I
          > read in another newsgroup that inserting an html hidden text box made the
          > trick, and it actually does, but in my page I have more than one web[/color]
          control[color=blue]
          > that have their independient "forms" (in the .NET environment, it makes it
          > to be just one). And I need that, if the user is, say, writing the[/color]
          keywords[color=blue]
          > to perform a search, the enter key submits this form, but if he is writing
          > his username and password to login, the enter key submits this other
          > one........
          >
          > Does anyone know how to do this?
          >
          > Best Regards,
          >
          > SC
          >
          >[/color]


          Comment

          • S. Justin Gengo

            #6
            Re: ENTER key to submit forms

            Sandra,

            No problem! :-)

            It's pretty easy. Once you've dragged the component onto the page switch to
            the code behind page.

            If you didn't change the default name of the component when it was placed on
            the page you would refer to it as: Javascript1

            And you can attach it to as many text boxes as you want like this:

            '---Page is the page object literally type "Page" there.
            '---Textbox1 is the id of your text box.
            '---Button1 is the id of the button you want to fire when the enter key is
            ' pressed while in this text box.
            Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
            System.EventArg s) Handles MyBase.Load
            Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
            Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
            End Sub

            --
            Sincerely,

            S. Justin Gengo, MCP
            Web Developer / Programmer

            Free code library at:


            "Out of chaos comes order."
            Nietzche


            "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
            news:OilzsK5sDH A.1884@TK2MSFTN GP10.phx.gbl...[color=blue]
            > I'm sorry, could you please tell me how to attach this eventhandler to my
            > textboxes? I am working with <asp:textbox> . does it work with them?
            > Sorry :'(
            >
            > SC
            > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
            > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=green]
            > > Hello,
            > >
            > > I want to know what I have to do to make the enter key to submit forms.[/color][/color]
            I[color=blue][color=green]
            > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
            the[color=blue][color=green]
            > > trick, and it actually does, but in my page I have more than one web[/color]
            > control[color=green]
            > > that have their independient "forms" (in the .NET environment, it makes[/color][/color]
            it[color=blue][color=green]
            > > to be just one). And I need that, if the user is, say, writing the[/color]
            > keywords[color=green]
            > > to perform a search, the enter key submits this form, but if he is[/color][/color]
            writing[color=blue][color=green]
            > > his username and password to login, the enter key submits this other
            > > one........
            > >
            > > Does anyone know how to do this?
            > >
            > > Best Regards,
            > >
            > > SC
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Sandra Castellanos

              #7
              Re: ENTER key to submit forms

              Being stupid again. It worked, thanks a lot :'(
              SC
              "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
              news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Hello,
              >
              > I want to know what I have to do to make the enter key to submit forms. I
              > read in another newsgroup that inserting an html hidden text box made the
              > trick, and it actually does, but in my page I have more than one web[/color]
              control[color=blue]
              > that have their independient "forms" (in the .NET environment, it makes it
              > to be just one). And I need that, if the user is, say, writing the[/color]
              keywords[color=blue]
              > to perform a search, the enter key submits this form, but if he is writing
              > his username and password to login, the enter key submits this other
              > one........
              >
              > Does anyone know how to do this?
              >
              > Best Regards,
              >
              > SC
              >
              >[/color]


              Comment

              • Sandra Castellanos

                #8
                Re: ENTER key to submit forms

                Does it work if the user has the autocomplete enabled? In the page I added
                the eventhandler, if I have autocomplete enabled, and I select an item from
                the things with which I had filled that textbox before and I hit enter (just
                as I always do), then it just does nothing, the form goes cleared and the
                buttons don't work anymore.


                "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                news:O%23l5$U5s DHA.1060@TK2MSF TNGP12.phx.gbl. ..[color=blue]
                > Sandra,
                >
                > No problem! :-)
                >
                > It's pretty easy. Once you've dragged the component onto the page switch[/color]
                to[color=blue]
                > the code behind page.
                >
                > If you didn't change the default name of the component when it was placed[/color]
                on[color=blue]
                > the page you would refer to it as: Javascript1
                >
                > And you can attach it to as many text boxes as you want like this:
                >
                > '---Page is the page object literally type "Page" there.
                > '---Textbox1 is the id of your text box.
                > '---Button1 is the id of the button you want to fire when the enter key is
                > ' pressed while in this text box.
                > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
                > System.EventArg s) Handles MyBase.Load
                > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
                > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
                > End Sub
                >
                > --
                > Sincerely,
                >
                > S. Justin Gengo, MCP
                > Web Developer / Programmer
                >
                > Free code library at:
                > www.aboutfortunate.com
                >
                > "Out of chaos comes order."
                > Nietzche
                >
                >
                > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                > news:OilzsK5sDH A.1884@TK2MSFTN GP10.phx.gbl...[color=green]
                > > I'm sorry, could you please tell me how to attach this eventhandler to[/color][/color]
                my[color=blue][color=green]
                > > textboxes? I am working with <asp:textbox> . does it work with them?
                > > Sorry :'(
                > >
                > > SC
                > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                > > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=darkred]
                > > > Hello,
                > > >
                > > > I want to know what I have to do to make the enter key to submit[/color][/color][/color]
                forms.[color=blue]
                > I[color=green][color=darkred]
                > > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
                > the[color=green][color=darkred]
                > > > trick, and it actually does, but in my page I have more than one web[/color]
                > > control[color=darkred]
                > > > that have their independient "forms" (in the .NET environment, it[/color][/color][/color]
                makes[color=blue]
                > it[color=green][color=darkred]
                > > > to be just one). And I need that, if the user is, say, writing the[/color]
                > > keywords[color=darkred]
                > > > to perform a search, the enter key submits this form, but if he is[/color][/color]
                > writing[color=green][color=darkred]
                > > > his username and password to login, the enter key submits this other
                > > > one........
                > > >
                > > > Does anyone know how to do this?
                > > >
                > > > Best Regards,
                > > >
                > > > SC
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • S. Justin Gengo

                  #9
                  Re: ENTER key to submit forms

                  Sandra,

                  It only works if the textbox has focus. That's the way javascript works. If
                  you don't click in the text box or move the cursor when you use autocomplete
                  to select something the text box doesn't have focus the autocomplete drop
                  down does. I have no idea how to attach a javascript to that.

                  --
                  Sincerely,

                  S. Justin Gengo, MCP
                  Web Developer / Programmer

                  Free code library at:


                  "Out of chaos comes order."
                  Nietzche


                  "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                  news:uIJaAk5sDH A.1876@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > Does it work if the user has the autocomplete enabled? In the page I added
                  > the eventhandler, if I have autocomplete enabled, and I select an item[/color]
                  from[color=blue]
                  > the things with which I had filled that textbox before and I hit enter[/color]
                  (just[color=blue]
                  > as I always do), then it just does nothing, the form goes cleared and the
                  > buttons don't work anymore.
                  >
                  >
                  > "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                  > news:O%23l5$U5s DHA.1060@TK2MSF TNGP12.phx.gbl. ..[color=green]
                  > > Sandra,
                  > >
                  > > No problem! :-)
                  > >
                  > > It's pretty easy. Once you've dragged the component onto the page switch[/color]
                  > to[color=green]
                  > > the code behind page.
                  > >
                  > > If you didn't change the default name of the component when it was[/color][/color]
                  placed[color=blue]
                  > on[color=green]
                  > > the page you would refer to it as: Javascript1
                  > >
                  > > And you can attach it to as many text boxes as you want like this:
                  > >
                  > > '---Page is the page object literally type "Page" there.
                  > > '---Textbox1 is the id of your text box.
                  > > '---Button1 is the id of the button you want to fire when the enter key[/color][/color]
                  is[color=blue][color=green]
                  > > ' pressed while in this text box.
                  > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
                  > > System.EventArg s) Handles MyBase.Load
                  > > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
                  > > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
                  > > End Sub
                  > >
                  > > --
                  > > Sincerely,
                  > >
                  > > S. Justin Gengo, MCP
                  > > Web Developer / Programmer
                  > >
                  > > Free code library at:
                  > > www.aboutfortunate.com
                  > >
                  > > "Out of chaos comes order."
                  > > Nietzche
                  > >
                  > >
                  > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                  > > news:OilzsK5sDH A.1884@TK2MSFTN GP10.phx.gbl...[color=darkred]
                  > > > I'm sorry, could you please tell me how to attach this eventhandler to[/color][/color]
                  > my[color=green][color=darkred]
                  > > > textboxes? I am working with <asp:textbox> . does it work with them?
                  > > > Sorry :'(
                  > > >
                  > > > SC
                  > > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                  > > > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...
                  > > > > Hello,
                  > > > >
                  > > > > I want to know what I have to do to make the enter key to submit[/color][/color]
                  > forms.[color=green]
                  > > I[color=darkred]
                  > > > > read in another newsgroup that inserting an html hidden text box[/color][/color][/color]
                  made[color=blue][color=green]
                  > > the[color=darkred]
                  > > > > trick, and it actually does, but in my page I have more than one web
                  > > > control
                  > > > > that have their independient "forms" (in the .NET environment, it[/color][/color]
                  > makes[color=green]
                  > > it[color=darkred]
                  > > > > to be just one). And I need that, if the user is, say, writing the
                  > > > keywords
                  > > > > to perform a search, the enter key submits this form, but if he is[/color]
                  > > writing[color=darkred]
                  > > > > his username and password to login, the enter key submits this other
                  > > > > one........
                  > > > >
                  > > > > Does anyone know how to do this?
                  > > > >
                  > > > > Best Regards,
                  > > > >
                  > > > > SC
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Bill Cohagan

                    #10
                    Re: ENTER key to submit forms

                    On a related note, I'm interested in AVOIDING having the form submitted when
                    a user hits the ENTER key (say just after selecting an Option button). Is
                    there a way to force the user to click the Submit button instead?

                    Thanks in advance,
                    Bill

                    "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                    news:eVhFpQ3sDH A.540@tk2msftng p13.phx.gbl...[color=blue]
                    > Sandra,
                    >
                    > I've created a javascript component with some commonly used javascripts in
                    > it. One of them does exactly what you are looking for.
                    >
                    > The component is free, comes with a help file, and the entire projects
                    > source code is available on my web site: www.aboutfortunate.com. Just[/color]
                    click[color=blue]
                    > on the code library link and then click on the "Javascript " button in the
                    > menu on the left.
                    >
                    > Even if you don't want to use the entire component the code you need to
                    > create your own is in the project.
                    >
                    > --
                    > Sincerely,
                    >
                    > S. Justin Gengo, MCP
                    > Web Developer / Programmer
                    >
                    > Free code library at:
                    > www.aboutfortunate.com
                    >
                    > "Out of chaos comes order."
                    > Nietzche
                    >
                    >
                    > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                    > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=green]
                    > > Hello,
                    > >
                    > > I want to know what I have to do to make the enter key to submit forms.[/color][/color]
                    I[color=blue][color=green]
                    > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
                    the[color=blue][color=green]
                    > > trick, and it actually does, but in my page I have more than one web[/color]
                    > control[color=green]
                    > > that have their independient "forms" (in the .NET environment, it makes[/color][/color]
                    it[color=blue][color=green]
                    > > to be just one). And I need that, if the user is, say, writing the[/color]
                    > keywords[color=green]
                    > > to perform a search, the enter key submits this form, but if he is[/color][/color]
                    writing[color=blue][color=green]
                    > > his username and password to login, the enter key submits this other
                    > > one........
                    > >
                    > > Does anyone know how to do this?
                    > >
                    > > Best Regards,
                    > >
                    > > SC
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Sandra Castellanos

                      #11
                      Re: ENTER key to submit forms

                      Sorry, I think there is a missunderstandi ng here. If the user has
                      autocomplete enabled in his browser, when the focus is in a textbox the
                      browser sometimes shows it the diferent things with which he has completed
                      that field, the user can, pressing the arrows select one of those and with
                      enter that item gets selected. All the time, the focus has been in the text
                      box. Now, if I have this handler for the keypressed event, that event is
                      raised when the user selects one word to fill the box. That's what is
                      happenning to me now


                      "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                      news:OMpDoV6sDH A.2360@TK2MSFTN GP10.phx.gbl...[color=blue]
                      > Sandra,
                      >
                      > It only works if the textbox has focus. That's the way javascript works.[/color]
                      If[color=blue]
                      > you don't click in the text box or move the cursor when you use[/color]
                      autocomplete[color=blue]
                      > to select something the text box doesn't have focus the autocomplete drop
                      > down does. I have no idea how to attach a javascript to that.
                      >
                      > --
                      > Sincerely,
                      >
                      > S. Justin Gengo, MCP
                      > Web Developer / Programmer
                      >
                      > Free code library at:
                      > www.aboutfortunate.com
                      >
                      > "Out of chaos comes order."
                      > Nietzche
                      >
                      >
                      > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                      > news:uIJaAk5sDH A.1876@TK2MSFTN GP09.phx.gbl...[color=green]
                      > > Does it work if the user has the autocomplete enabled? In the page I[/color][/color]
                      added[color=blue][color=green]
                      > > the eventhandler, if I have autocomplete enabled, and I select an item[/color]
                      > from[color=green]
                      > > the things with which I had filled that textbox before and I hit enter[/color]
                      > (just[color=green]
                      > > as I always do), then it just does nothing, the form goes cleared and[/color][/color]
                      the[color=blue][color=green]
                      > > buttons don't work anymore.
                      > >
                      > >
                      > > "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                      > > news:O%23l5$U5s DHA.1060@TK2MSF TNGP12.phx.gbl. ..[color=darkred]
                      > > > Sandra,
                      > > >
                      > > > No problem! :-)
                      > > >
                      > > > It's pretty easy. Once you've dragged the component onto the page[/color][/color][/color]
                      switch[color=blue][color=green]
                      > > to[color=darkred]
                      > > > the code behind page.
                      > > >
                      > > > If you didn't change the default name of the component when it was[/color][/color]
                      > placed[color=green]
                      > > on[color=darkred]
                      > > > the page you would refer to it as: Javascript1
                      > > >
                      > > > And you can attach it to as many text boxes as you want like this:
                      > > >
                      > > > '---Page is the page object literally type "Page" there.
                      > > > '---Textbox1 is the id of your text box.
                      > > > '---Button1 is the id of the button you want to fire when the enter[/color][/color][/color]
                      key[color=blue]
                      > is[color=green][color=darkred]
                      > > > ' pressed while in this text box.
                      > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
                      > > > System.EventArg s) Handles MyBase.Load
                      > > > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox1, Button1)
                      > > > Javascript1.Tex tBoxEnterEventH andler(Page, TextBox2, Button2)
                      > > > End Sub
                      > > >
                      > > > --
                      > > > Sincerely,
                      > > >
                      > > > S. Justin Gengo, MCP
                      > > > Web Developer / Programmer
                      > > >
                      > > > Free code library at:
                      > > > www.aboutfortunate.com
                      > > >
                      > > > "Out of chaos comes order."
                      > > > Nietzche
                      > > >
                      > > >
                      > > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                      > > > news:OilzsK5sDH A.1884@TK2MSFTN GP10.phx.gbl...
                      > > > > I'm sorry, could you please tell me how to attach this eventhandler[/color][/color][/color]
                      to[color=blue][color=green]
                      > > my[color=darkred]
                      > > > > textboxes? I am working with <asp:textbox> . does it work with them?
                      > > > > Sorry :'(
                      > > > >
                      > > > > SC
                      > > > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                      > > > > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...
                      > > > > > Hello,
                      > > > > >
                      > > > > > I want to know what I have to do to make the enter key to submit[/color]
                      > > forms.[color=darkred]
                      > > > I
                      > > > > > read in another newsgroup that inserting an html hidden text box[/color][/color]
                      > made[color=green][color=darkred]
                      > > > the
                      > > > > > trick, and it actually does, but in my page I have more than one[/color][/color][/color]
                      web[color=blue][color=green][color=darkred]
                      > > > > control
                      > > > > > that have their independient "forms" (in the .NET environment, it[/color]
                      > > makes[color=darkred]
                      > > > it
                      > > > > > to be just one). And I need that, if the user is, say, writing the
                      > > > > keywords
                      > > > > > to perform a search, the enter key submits this form, but if he is
                      > > > writing
                      > > > > > his username and password to login, the enter key submits this[/color][/color][/color]
                      other[color=blue][color=green][color=darkred]
                      > > > > > one........
                      > > > > >
                      > > > > > Does anyone know how to do this?
                      > > > > >
                      > > > > > Best Regards,
                      > > > > >
                      > > > > > SC
                      > > > > >
                      > > > > >
                      > > > >
                      > > > >
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • S. Justin Gengo

                        #12
                        Re: ENTER key to submit forms

                        Bill,

                        You could take the same script and instead of having it click the button
                        when the javascript senses that the enter key is pressed you could return
                        "false" which would make it as if the enter key was never pressed.

                        Something like this:


                        TextBox.Attribu tes.Add("onkeyd own", "javascript:if( (event.which &&
                        event.which == 13) || (event.keyCode && event.keyCode == 13)){return
                        false;}else return true;")



                        --
                        Sincerely,

                        S. Justin Gengo, MCP
                        Web Developer / Programmer

                        Free code library at:


                        "Out of chaos comes order."
                        Nietzche


                        "Bill Cohagan" <bill@teraXNOSP AMXquest.com> wrote in message
                        news:OxIjmh7sDH A.2508@TK2MSFTN GP12.phx.gbl...[color=blue]
                        > On a related note, I'm interested in AVOIDING having the form submitted[/color]
                        when[color=blue]
                        > a user hits the ENTER key (say just after selecting an Option button). Is
                        > there a way to force the user to click the Submit button instead?
                        >
                        > Thanks in advance,
                        > Bill
                        >
                        > "S. Justin Gengo" <sjgengo@aboutf ortunate.com> wrote in message
                        > news:eVhFpQ3sDH A.540@tk2msftng p13.phx.gbl...[color=green]
                        > > Sandra,
                        > >
                        > > I've created a javascript component with some commonly used javascripts[/color][/color]
                        in[color=blue][color=green]
                        > > it. One of them does exactly what you are looking for.
                        > >
                        > > The component is free, comes with a help file, and the entire projects
                        > > source code is available on my web site: www.aboutfortunate.com. Just[/color]
                        > click[color=green]
                        > > on the code library link and then click on the "Javascript " button in[/color][/color]
                        the[color=blue][color=green]
                        > > menu on the left.
                        > >
                        > > Even if you don't want to use the entire component the code you need to
                        > > create your own is in the project.
                        > >
                        > > --
                        > > Sincerely,
                        > >
                        > > S. Justin Gengo, MCP
                        > > Web Developer / Programmer
                        > >
                        > > Free code library at:
                        > > www.aboutfortunate.com
                        > >
                        > > "Out of chaos comes order."
                        > > Nietzche
                        > >
                        > >
                        > > "Sandra Castellanos" <sandrac@4brain storm.com> wrote in message
                        > > news:uX$z1G3sDH A.1740@TK2MSFTN GP12.phx.gbl...[color=darkred]
                        > > > Hello,
                        > > >
                        > > > I want to know what I have to do to make the enter key to submit[/color][/color][/color]
                        forms.[color=blue]
                        > I[color=green][color=darkred]
                        > > > read in another newsgroup that inserting an html hidden text box made[/color][/color]
                        > the[color=green][color=darkred]
                        > > > trick, and it actually does, but in my page I have more than one web[/color]
                        > > control[color=darkred]
                        > > > that have their independient "forms" (in the .NET environment, it[/color][/color][/color]
                        makes[color=blue]
                        > it[color=green][color=darkred]
                        > > > to be just one). And I need that, if the user is, say, writing the[/color]
                        > > keywords[color=darkred]
                        > > > to perform a search, the enter key submits this form, but if he is[/color][/color]
                        > writing[color=green][color=darkred]
                        > > > his username and password to login, the enter key submits this other
                        > > > one........
                        > > >
                        > > > Does anyone know how to do this?
                        > > >
                        > > > Best Regards,
                        > > >
                        > > > SC
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        Working...