prevent form submit ...

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default prevent form submit ...

    I have a web form with multiple part.
    I do want the user to click the submit button to post back, so I know which
    functionality was triggered.

    unfortunately, when the focus is any text box, if the user hit ENTER the
    form is submitted, how could prevent that ?

    thanks, ...
    Lloyd


    Lloyd Dupont Guest

  2. Similar Questions and Discussions

    1. Contact Form (php) - how to prevent new window
      My contact form works just fine, however, I currently have the target set to "_blank" which is not what I want. Rather than opening the .php file...
    2. Prevent Form Cache
      Hello~ I am looking for a method to prevent form entry fields from being cached. I need to prevent the user from being able to click on a forms...
    3. Prevent Form to run from external site
      Hello! Can anyone please tell me how can I do to prevent a Form to run from external site? I need that it just run in my site, like...
    4. Dupe Prevent on Form Submit
      I have an html form, that has fields and when the submit button is pressed, the information is transferred to a php file. Which then inserts the...
    5. Form Field/ Form Submit Problems (probably an easy answer...)
      Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works...
  3. #2

    Default Re: prevent form submit ...

    You can intercept the client side enter keypress event of the text box and
    then click the correct button using javascript code.
    Here's a good example:
    [url]http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18[/url]

    You could also try using this free control.
    [url]http://www.metabuilders.com/tools/DefaultButtons.aspx[/url]


    And here's a good article on the subject:
    [url]http://www.allasp.net/enterkey.aspx[/url]

    --
    I hope this helps,
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]


    "Lloyd Dupont" <lloyd@galador.net> wrote in message
    news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > I have a web form with multiple part.
    > I do want the user to click the submit button to post back, so I know
    which
    > functionality was triggered.
    >
    > unfortunately, when the focus is any text box, if the user hit ENTER the
    > form is submitted, how could prevent that ?
    >
    > thanks, ...
    > Lloyd
    >
    >

    Steve C. Orr, MCSD Guest

  4. #3

    Default Re: prevent form submit ...

    hehe, regarding your samples I found I could simply write:
    onkeydown="if ((event.which && event.which == 13) ||
    (event.keyCode && event.keyCode == 13))
    return false;"

    and that remove the form triggering !
    hhmm.. maybe I could a default button too... anyway thanks :-)


    "Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
    news:ex218c5XDHA.2236@TK2MSFTNGP10.phx.gbl...
    > You can intercept the client side enter keypress event of the text box and
    > then click the correct button using javascript code.
    > Here's a good example:
    > [url]http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18[/url]
    >
    > You could also try using this free control.
    > [url]http://www.metabuilders.com/tools/DefaultButtons.aspx[/url]
    >
    >
    > And here's a good article on the subject:
    > [url]http://www.allasp.net/enterkey.aspx[/url]
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD
    > [url]http://Steve.Orr.net[/url]
    >
    >
    > "Lloyd Dupont" <lloyd@galador.net> wrote in message
    > news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > > I have a web form with multiple part.
    > > I do want the user to click the submit button to post back, so I know
    > which
    > > functionality was triggered.
    > >
    > > unfortunately, when the focus is any text box, if the user hit ENTER the
    > > form is submitted, how could prevent that ?
    > >
    > > thanks, ...
    > > Lloyd
    > >
    > >
    >
    >

    Lloyd Dupont Guest

  5. #4

    Default Re: prevent form submit ...

    If the user hits enter it triggers exactly the same action as clicking the
    default submit button. What exactly are you trying to accomplish? If you
    don't want to allow the user to submit the form don't create any submit
    buttons... And if for some reason you have a script in your onclick event on
    the submit button then just move it to onsubmit event of the form...

    Jerry

    "Lloyd Dupont" <lloyd@galador.net> wrote in message
    news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > I have a web form with multiple part.
    > I do want the user to click the submit button to post back, so I know
    which
    > functionality was triggered.
    >
    > unfortunately, when the focus is any text box, if the user hit ENTER the
    > form is submitted, how could prevent that ?
    >
    > thanks, ...
    > Lloyd
    >
    >

    Jerry III Guest

  6. #5

    Default Re: prevent form submit ...

    Right, that was one of the examples in the links I gave you.
    I'm glad it worked out well for you.

    --
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]


    "Lloyd Dupont" <lloyd@galador.net> wrote in message
    news:uuxUoL6XDHA.1480@tk2msftngp13.phx.gbl...
    > hehe, regarding your samples I found I could simply write:
    > onkeydown="if ((event.which && event.which == 13) ||
    > (event.keyCode && event.keyCode == 13))
    > return false;"
    >
    > and that remove the form triggering !
    > hhmm.. maybe I could a default button too... anyway thanks :-)
    >
    >
    > "Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
    > news:ex218c5XDHA.2236@TK2MSFTNGP10.phx.gbl...
    > > You can intercept the client side enter keypress event of the text box
    and
    > > then click the correct button using javascript code.
    > > Here's a good example:
    > > [url]http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18[/url]
    > >
    > > You could also try using this free control.
    > > [url]http://www.metabuilders.com/tools/DefaultButtons.aspx[/url]
    > >
    > >
    > > And here's a good article on the subject:
    > > [url]http://www.allasp.net/enterkey.aspx[/url]
    > >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD
    > > [url]http://Steve.Orr.net[/url]
    > >
    > >
    > > "Lloyd Dupont" <lloyd@galador.net> wrote in message
    > > news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > > > I have a web form with multiple part.
    > > > I do want the user to click the submit button to post back, so I know
    > > which
    > > > functionality was triggered.
    > > >
    > > > unfortunately, when the focus is any text box, if the user hit ENTER
    the
    > > > form is submitted, how could prevent that ?
    > > >
    > > > thanks, ...
    > > > Lloyd
    > > >
    > > >
    > >
    > >
    >
    >

    Steve C. Orr, MCSD Guest

  7. #6

    Default Re: prevent form submit ...

    on a wider note...this book will payback after about 1 day of javascript
    coding....

    Javascript & DHTML Cookbook ( Danny Goodman )
    [url]http://www.bookpool.com/.x/hywrfgtqor/sm/0596004672[/url]



    "Lloyd Dupont" <lloyd@galador.net> wrote in message
    news:uuxUoL6XDHA.1480@tk2msftngp13.phx.gbl...
    > hehe, regarding your samples I found I could simply write:
    > onkeydown="if ((event.which && event.which == 13) ||
    > (event.keyCode && event.keyCode == 13))
    > return false;"
    >
    > and that remove the form triggering !
    > hhmm.. maybe I could a default button too... anyway thanks :-)
    >
    >
    > "Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
    > news:ex218c5XDHA.2236@TK2MSFTNGP10.phx.gbl...
    > > You can intercept the client side enter keypress event of the text box
    and
    > > then click the correct button using javascript code.
    > > Here's a good example:
    > > [url]http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18[/url]
    > >
    > > You could also try using this free control.
    > > [url]http://www.metabuilders.com/tools/DefaultButtons.aspx[/url]
    > >
    > >
    > > And here's a good article on the subject:
    > > [url]http://www.allasp.net/enterkey.aspx[/url]
    > >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD
    > > [url]http://Steve.Orr.net[/url]
    > >
    > >
    > > "Lloyd Dupont" <lloyd@galador.net> wrote in message
    > > news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > > > I have a web form with multiple part.
    > > > I do want the user to click the submit button to post back, so I know
    > > which
    > > > functionality was triggered.
    > > >
    > > > unfortunately, when the focus is any text box, if the user hit ENTER
    the
    > > > form is submitted, how could prevent that ?
    > > >
    > > > thanks, ...
    > > > Lloyd
    > > >
    > > >
    > >
    > >
    >
    >

    PJ Guest

  8. #7

    Default Re: prevent form submit ...

    I have multiple section on my web page.
    like 'unregister section' and 'update profile section'

    so I could not 'just submit' the form.
    I need the user to click on one button, so I know if it unregister, or if it
    just update on its profile.

    otherwise, mmhh.. what would you do ?

    and no, I rather have them both on the same page than on 2 empty otherwise
    page.

    "Jerry III" <jerryiii@hotmail.com> a écrit dans le message de
    news:%23d97GN6XDHA.2572@TK2MSFTNGP09.phx.gbl...
    > If the user hits enter it triggers exactly the same action as clicking the
    > default submit button. What exactly are you trying to accomplish? If you
    > don't want to allow the user to submit the form don't create any submit
    > buttons... And if for some reason you have a script in your onclick event
    on
    > the submit button then just move it to onsubmit event of the form...
    >
    > Jerry
    >
    > "Lloyd Dupont" <lloyd@galador.net> wrote in message
    > news:OCg$tR5XDHA.1480@tk2msftngp13.phx.gbl...
    > > I have a web form with multiple part.
    > > I do want the user to click the submit button to post back, so I know
    > which
    > > functionality was triggered.
    > >
    > > unfortunately, when the focus is any text box, if the user hit ENTER the
    > > form is submitted, how could prevent that ?
    > >
    > > thanks, ...
    > > Lloyd
    > >
    > >
    >
    >

    Lloyd Dupont Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139