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

form unasked submitting

Gu
hi to all!
how can i prevent the "return / enter" key to submit the current form
if hit in a text input? i've actually added the code:
onKeyPress="if(event.KeyCode==13){doGivenFunction( );}"
to make it react the way i'd like (calling a function and not
submitting the form), but it doesn not work.
any suggestion?

thanks in advance for any eventual help
Jul 23 '05 #1
5 3603
Gu wrote on 13 mei 2005 in comp.lang.javascript:
hi to all!
how can i prevent the "return / enter" key to submit the current form
if hit in a text input? i've actually added the code:
onKeyPress="if(event.KeyCode==13){doGivenFunction( );}"
to make it react the way i'd like (calling a function and not
submitting the form), but it doesn not work.
any suggestion?

<input onKeyPress="return !(event.KeyCode==13)">press</div>
You will need to cancell the keypress

thanks in advance for any eventual help


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2
Evertjan. wrote on 13 mei 2005 in comp.lang.javascript:
Gu wrote on 13 mei 2005 in comp.lang.javascript:
hi to all!
how can i prevent the "return / enter" key to submit the current form
if hit in a text input? i've actually added the code:
onKeyPress="if(event.KeyCode==13){doGivenFunction( );}"
to make it react the way i'd like (calling a function and not
submitting the form), but it doesn not work.
any suggestion?

<input onKeyPress="return !(event.KeyCode==13)">

You will need to cancell the keypress


Sorry, pressed the "send" button too soon

KeyCode should be keyCode
Try this:

<input onKeyPress="return(event.keyCode!=13)">

thanks in advance for any eventual help


eventual like in event.keyCode? ;-}
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3
Gu
On 13 May 2005 19:09:12 GMT, "Evertjan."
<ex**************@interxnl.net> wrote:

eventual like in event.keyCode? ;-}


LOL
Jul 23 '05 #4
Gu
On 13 May 2005 19:09:12 GMT, "Evertjan."
<ex**************@interxnl.net> wrote:
Evertjan. wrote on 13 mei 2005 in comp.lang.javascript:
Gu wrote on 13 mei 2005 in comp.lang.javascript:
hi to all!
how can i prevent the "return / enter" key to submit the current form
if hit in a text input? i've actually added the code:
onKeyPress="if(event.KeyCode==13){doGivenFunction( );}"
to make it react the way i'd like (calling a function and not
submitting the form), but it doesn not work.
any suggestion?

<input onKeyPress="return !(event.KeyCode==13)">

You will need to cancell the keypress


Sorry, pressed the "send" button too soon

KeyCode should be keyCode
Try this:

<input onKeyPress="return(event.keyCode!=13)">

thanks in advance for any eventual help


eventual like in event.keyCode? ;-}

hmm.. well, you code works, thanks for that, in preventing the form to
submit, but how can i use it for triggering a function when enter is
pressed? the current code is:

onKeyPress="if(event.keyCode==13){invia();}"

Jul 23 '05 #5
Gu wrote on 14 mei 2005 in comp.lang.javascript:
Try this:

<input onKeyPress="return(event.keyCode!=13)">
thanks in advance for any eventual help

eventual like in event.keyCode? ;-}


hmm.. well, you code works, thanks for that, in preventing the form to
submit, but how can i use it for triggering a function when enter is
pressed? the current code is:

onKeyPress="if(event.keyCode==13){invia();}"


This has been told zillions of times in this NG,
and is available in the archive.

onKeyPress="if(event.keyCode==13){invia();return false}"

If you want both the execution of invia()
and the prevention of submission.

Try:

onKeyPress=
"if(event.keyCode==13){alert('You pressed enter');return false}"

Or

onKeyPress=
"if(event.keyCode==13){return confirm('Do you really want submission?')}"

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6

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

Similar topics

15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
5
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----==...
2
by: Esa | last post by:
Hi, I'm having problems with one strange web system where submitting an application and making queries about its handling status require a series of form submits and response parsing - all in...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
4
by: Super Steve | last post by:
I'm trying to write a little script that disables the submit button on a form, changes the text of the button, and then submits the form. Can anyone tell me why this works ok: <input...
3
by: kgbalaji1980 | last post by:
Hi all, i want the jscript coding for more than one form in one page and submitting the same . ie one parent form and one append button when we click that button one child form will display...
18
by: NavinM | last post by:
I have a couple of forms that are misbehaving in FireFox, but work fine in IE. when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the...
1
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit...
5
by: Rider | last post by:
Hi All, Here is the reason why i ak asking for ur help. I have a edit form in which the values already stored in DB are populated. User can edit some or all the values in the form. then he...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
0
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,...

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.