473,569 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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){doGivenFunc tion();}"
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 3612
Gu wrote on 13 mei 2005 in comp.lang.javas cript:
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){doGivenFunc tion();}"
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="ret urn !(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.javas cript:
Gu wrote on 13 mei 2005 in comp.lang.javas cript:
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){doGivenFunc tion();}"
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="ret urn !(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="ret urn(event.keyCo de!=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.javas cript:
Gu wrote on 13 mei 2005 in comp.lang.javas cript:
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){doGivenFunc tion();}"
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="ret urn !(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="ret urn(event.keyCo de!=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.javas cript:
Try this:

<input onKeyPress="ret urn(event.keyCo de!=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();ret urn false}"

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

Try:

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

Or

onKeyPress=
"if(event.keyCo de==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
6556
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 the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The...
5
1897
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 ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000...
2
2264
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 HTML. Luckily other interfaces are "modern" using xml file up/downloads without any difficulties... I'm not very used to .NET-environment yet, so...
11
2977
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 certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the...
4
2787
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 type="button" value="Submit" onClick="this.disabled=true; this.value = 'Submitting...'; this.form.submit();"> But when I try to make a function it doesn't...
3
1893
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 and so on. we have to submitting for the same regards Balaji
18
13101
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 submission if there is an error. Sample (obviously not working code): <html> <head> <script type="text/javascript"> function Submit() {
1
3201
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 button". when "submit" button pressed, call the "servlet" in this popup window and then close the "popup" window. <SCRIPT LANGUAGE="JavaScript"> ...
5
10305
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 submit the form. NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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...
1
7681
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...
0
7983
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...
0
5228
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...
0
3662
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...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.