473,240 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

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
Nov 17 '05 #1
6 1915
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:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Lloyd Dupont" <ll***@galador.net> wrote in message
news:OC**************@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

Nov 17 '05 #2
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" <St***@Orr.net> wrote in message
news:ex**************@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:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Lloyd Dupont" <ll***@galador.net> wrote in message
news:OC**************@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


Nov 17 '05 #3
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" <ll***@galador.net> wrote in message
news:OC**************@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

Nov 17 '05 #4
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
http://Steve.Orr.net
"Lloyd Dupont" <ll***@galador.net> wrote in message
news:uu**************@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" <St***@Orr.net> wrote in message
news:ex**************@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:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Lloyd Dupont" <ll***@galador.net> wrote in message
news:OC**************@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



Nov 17 '05 #5
PJ
on a wider note...this book will payback after about 1 day of javascript
coding....

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

"Lloyd Dupont" <ll***@galador.net> wrote in message
news:uu**************@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" <St***@Orr.net> wrote in message
news:ex**************@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:
http://www.kamp-hansen.dk/pages/show...d=21&menuid=18

You could also try using this free control.
http://www.metabuilders.com/tools/DefaultButtons.aspx
And here's a good article on the subject:
http://www.allasp.net/enterkey.aspx

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Lloyd Dupont" <ll***@galador.net> wrote in message
news:OC**************@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



Nov 17 '05 #6
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" <je******@hotmail.com> a écrit dans le message de
news:%2****************@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" <ll***@galador.net> wrote in message
news:OC**************@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


Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: entoone | last post by:
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 data into my sql database. How can I go about...
2
by: anonieko | last post by:
Scenario: You have a page that is TOO slow to refresh. But it allows partial flushing of html contents. I.e. Submit button already appears but you don't want your users to click on it prematurely...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
2
by: APA | last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit button from firing? This is completely useless. I...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.