473,700 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1937
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******** ******@tk2msftn gp13.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.ne t> wrote in message
news:ex******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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******** ******@tk2msftn gp13.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******** ******@tk2msftn gp13.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.ne t> wrote in message
news:ex******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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******** ******@tk2msftn gp13.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.ne t> wrote in message
news:ex******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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******@hotma il.com> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP09.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******** ******@tk2msftn gp13.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
5455
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 ensuring that someone isn't able to submit thier information twice, or to somehow have the database checked before inserting the information, to see if it's there already. I have some duplicates happening and would like to stop it.
2
3815
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 because other parts are still coming. Here I put a javascript the will enable only submit button only after 5 seconds after the page is load fully.
14
2341
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) {alert("Temperature entered is out of range."); return;} } I enter data into the first textbox and move the cursor to the second textbox. The function is properly called. Since textbox2 is empty, when I
2
2848
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 need some custom javascript validation on form submit but why does is kill the submit button event handler? Submit buttons don't use __doPostBack so what is being effected?
0
8644
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9074
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8924
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7807
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5902
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4656
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.