473,408 Members | 2,839 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,408 software developers and data experts.

Need to ignore Enter key in Form

I really need to stop users from reposting the form with Enter or Return
keys. It bypasses so many onClick validations that nothign works if they use
Enter. I must force the user to CLICK on the "Save" button on my aspx page
and instead totally ignore the Enter Key.

I figured I could use this code

function EnterKeyPress(){ if (window.event.keyCode==13){ alert('No Enter
please'); return false; } }

and call that from
<body onkeydown="javascript:EnterKeyPress();">

But that doesn't work.. sure it triggers but it still makes the page
postback.

OR.. any better solution that I'm not bright enough to think of is welcomed!

please help/
Lars
Nov 19 '05 #1
1 1797
try this, in the function:

// cancel the default submit
event.returnValue=false;
event.cancel = true;

masoud
"Lars Netzel" <la*********@NO-SPAM.qlogic.se> wrote in message
news:uX*************@TK2MSFTNGP15.phx.gbl...
I really need to stop users from reposting the form with Enter or Return
keys. It bypasses so many onClick validations that nothign works if they use Enter. I must force the user to CLICK on the "Save" button on my aspx page
and instead totally ignore the Enter Key.

I figured I could use this code

function EnterKeyPress(){ if (window.event.keyCode==13){ alert('No Enter
please'); return false; } }

and call that from
<body onkeydown="javascript:EnterKeyPress();">

But that doesn't work.. sure it triggers but it still makes the page
postback.

OR.. any better solution that I'm not bright enough to think of is welcomed!
please help/
Lars

Nov 19 '05 #2

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

Similar topics

2
by: JackM | last post by:
Let me attempt to explain my problem. I have a crude php script that takes a text list of songs that was generated by an mp3 list program and translates each entry into the form where they can be...
6
by: Rob Meade | last post by:
Lo all, I was just running through some code I was writing for a site and when it came to the 'exact phrase' search type I wasn't sure whether that should run through and ignore the words in the...
10
by: Tom | last post by:
I am looking for some ideas for how to design the layout of the form for data entry and to display the data for the following situation: There are many sales associates. A sales associate can work...
5
by: matrim | last post by:
I have trouble knowing how to call the function and passing parameters. Can someone help point out where things need to go? It's a basic program to figure out the cost per inch of pizza of either a...
2
by: HarisHohkl | last post by:
Hi, I've this function in a class to update the total value.but when i try to remove the these row highlight in Bold it crash, what should i do???? void display_total_value() { double...
31
by: Don Leverton | last post by:
Hi Folks, I've been away from this NG for quite a while, persuing other interests etc. I have made a few posts / replies here lately, and find this whole NG thing a little awkward and...
1
by: aguai | last post by:
hi Im trying to do is something should be simple: I wish to ignore the key....'\n' my test is Like this /*di.cpp*/ #include <cstdio> #include <cstdlib> #include <iostream> using namespace...
6
by: Mark B | last post by:
I have a function that looks up a SQL table to see if a search term matches. It works fine but so far there are two things yet to work: 1) After entering a search term and pressing Enter, nothing...
14
by: confusedfusion | last post by:
Not sure how many form submissions that have been lost over the years before I started but the company has a contact form that the required fields when validation fails the error message is going...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.