473,466 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to make a form that won't submit

Hi,

I have a web page with some form controls on it. When the user presses the
'OK' button, some javascript talks to another page in another window. This
form is never destined for the server so I don't want it to have any concept
of "submit".

However, I have noticed that pressing enter in a text field will submit the
form to the server. Because I haven't specified a form action, it just tries
to post to the root URL for my site which obviously doesn't work.

Currently I'm doing the processing in the onclick event of the button
because I've heard that <form action="javascript:..."> is not portable. Is
there any way to specify that a form is not submittable? I don't really want
to have keypress handlers on every text field because I'm sure there is a
proper way to achieve this.

Andy

Jul 20 '05 #1
3 2894
Andy Fish wrote:
I have a web page with some form controls on it. When the user presses the
'OK' button, some javascript talks to another page in another window. This
form is never destined for the server so I don't want it to have any
concept of "submit". [snip]

It sounds like you don't want a <form> element at all. Unless you need to
support a browser that can't handle <input> elements outside forms
(Netscape 4?), just remove the <form> element.

Is there any way to specify that a form is not submittable?

[snip]

<form onsubmit="return false;" ...>
--
Jim Dabell

Jul 20 '05 #2
Thanks, the
onsubmit="return false;"
is exactly what I was looking for.

the reason I had a form was that it seemed to be the best way to refer to
the controls within javascript i.e.
document.myForm.myTextBox

Andy

"Jim Dabell" <ji********@jimdabell.com> wrote in message
news:T-********************@giganews.com...
Andy Fish wrote:
I have a web page with some form controls on it. When the user presses the 'OK' button, some javascript talks to another page in another window. This form is never destined for the server so I don't want it to have any
concept of "submit".

[snip]

It sounds like you don't want a <form> element at all. Unless you need to
support a browser that can't handle <input> elements outside forms
(Netscape 4?), just remove the <form> element.

Is there any way to specify that a form is not submittable?

[snip]

<form onsubmit="return false;" ...>
--
Jim Dabell

Jul 20 '05 #3
<form onSubmit="return false;">?
Jul 20 '05 #4

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

Similar topics

12
by: Roger Price | last post by:
Thank you to Yang (Is that your first name?) and Andy for your suggestions. I am 99% of the way there but now cannot get the "Reset" button to work. I have included the whole of my code and...
1
by: Chris Nelder | last post by:
I think I must be losing my mind here. I've got the same page running on two different machines. I do the same form post on both, and on one machine I get Request.Form.Count=21 and on the other...
4
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM:...
6
by: Joop | last post by:
Hi all, I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-) So, here's my problem : I've created a table in my document, presenting a list of items, one can 'select' by clicking...
2
by: Wysiwyg | last post by:
I'm going back to a previous asp.net (C#) web project after a few months of inactivity and my first form, the login, won't submit. I ran with the debugger and still can't see how to resolve this. I...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
3
by: prodizy | last post by:
Hi, In Firefox, what's the best way of tracking the form submit? The following are two ways I tried, but they won't work if the form is submitted through JavaScript. Method 1: using the...
10
by: kelvin | last post by:
Hi, A difficult question. I have a form that I used to submit to https://www. paypal.com/cgi-bin/ webscr <form action="https://www. paypal.com/cgi-bin/webscr" method="post"> Now I need to...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
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
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
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,...
1
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.