473,698 Members | 2,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

event handler problem in large complex form

I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.

does any one else have this problem, and is there a work-round?

--
Arthur Rusdell-Wilson
Jul 23 '05 #1
8 1338


Arthur Rusdell-Wilson wrote:
I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.


Does that happen with one particular browser? Or with different ones?
Is there perhaps a script error happening so that the return false
statement is not reached?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
"Arthur Rusdell-Wilson" <ar****@kitekon sultants.co.uk> wrote in message
news:db******** ***********@new s.demon.co.uk.. .
I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.

does any one else have this problem, and is there a work-round?

--
Arthur Rusdell-Wilson


It's likely you aren't returning the value returned from the JavaScript
function to the event:

<form ... onsubmit="valid ate(this);">

The above won't ever stop the form submission even if the function is
defined as:

function validate() { return false; }

In order for the function to prevent form submission, you must return
the value to the event:

<form ... onsubmit="retur n validate(this); ">

If you have this, and you've verified that false (not "false") is
actually being returned (using <form ...
onsubmit="alert (validate(this) );">), then it's a browser implementation
bug and there won't be any work-around short of changing browsers.

I doubt very much it is a browser implementation bug, and instead one of
the two possibilities I listed:

1) you aren't returning the value to the event
2) you are returning the string "false" instead of the boolean false

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
VK
> I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.
does any one else have this problem, and is there a work-round?


I encountered it several times (but very rarely). It was always
connected with too long delay before you approve/cancel the bubble.
Always was helped by optimising the code (so your decision would come
out quickly). One of undescribed yet ghosts of JavaScript (like orphane
scripts). Never happens on primitive events like onclick/mousevove/etc.

Form submission / window closure / unload - the most probable places to
meet them. I call this "speedy bubbles", you may too if you want :-)

I guess it's a part of interface protection, so you couldn't lock user
on one page by simply putting each onsubmit/onbeforeunload/onload on
some endless process. Just an amateur guess...

Get the fat out of you script, it should help right away. Unless the
problem is im something else.

Jul 23 '05 #4

First off, give your page a document type, a DTD, say html4.1 strict dtd
and then validate, chances are your page is malformed and Form is split by
some unclosed opened element in it:

<form> <input> <input> <table> .....</form> </table>
really in quirk mode will cut off the 1st Form at the <table> part as it
never closed IN IT, and more than likely will render a 2nd orphan Form
from the fragment, cutting off any children from the 1st Form. I've seen
such and JS does report that because you're eventing an element that's cut
off from the Parent element you think it belongs to.
<FORM> <input> <button> <select></select> <ANYELEMEENT> .....
</ANYELEMENT></form>

is the proper way and will keep all Form children with its parent.
Danny

On Tue, 12 Jul 2005 08:55:13 -0700, Arthur Rusdell-Wilson
<ar****@kitekon sultants.co.uk> wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #5
I think you are probably right. I worked on that assumption, and everything
now works ok. However I did find one or two other little bugs as I was doing
this, so not absolutely sure. Anyway, I have an approach now for avoiding
this problem in the future.

--
Arthur Rusdell-Wilson
"VK" <sc**********@y ahoo.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.
does any one else have this problem, and is there a work-round?


I encountered it several times (but very rarely). It was always
connected with too long delay before you approve/cancel the bubble.
Always was helped by optimising the code (so your decision would come
out quickly). One of undescribed yet ghosts of JavaScript (like orphane
scripts). Never happens on primitive events like onclick/mousevove/etc.

Form submission / window closure / unload - the most probable places to
meet them. I call this "speedy bubbles", you may too if you want :-)

I guess it's a part of interface protection, so you couldn't lock user
on one page by simply putting each onsubmit/onbeforeunload/onload on
some endless process. Just an amateur guess...

Get the fat out of you script, it should help right away. Unless the
problem is im something else.

Jul 23 '05 #6
See my reply to VK

--
Arthur, on behalf of Kite Konsultants

"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:42******** *************** @newsread2.arco r-online.net...


Arthur Rusdell-Wilson wrote:
I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.


Does that happen with one particular browser? Or with different ones?
Is there perhaps a script error happening so that the return false
statement is not reached?

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #7
The problems you identify were not those that I had. I believe VK has the
answer, see my reply to his.

--
Arthur, on behalf of Kite Konsultants

"Grant Wagner" <gw*****@agrico reunited.com> wrote in message
news:0m******** ******@news2.mt s.net...
"Arthur Rusdell-Wilson" <ar****@kitekon sultants.co.uk> wrote in message
news:db******** ***********@new s.demon.co.uk.. .
I find that in a large form (especially if there is a table within the
form?) that the form is submitted to my server-side script even when a
JavaScript 'onsubmit' event handler returns 'false'.

does any one else have this problem, and is there a work-round?

--
Arthur Rusdell-Wilson


It's likely you aren't returning the value returned from the JavaScript
function to the event:

<form ... onsubmit="valid ate(this);">

The above won't ever stop the form submission even if the function is
defined as:

function validate() { return false; }

In order for the function to prevent form submission, you must return
the value to the event:

<form ... onsubmit="retur n validate(this); ">

If you have this, and you've verified that false (not "false") is
actually being returned (using <form ...
onsubmit="alert (validate(this) );">), then it's a browser implementation
bug and there won't be any work-around short of changing browsers.

I doubt very much it is a browser implementation bug, and instead one of
the two possibilities I listed:

1) you aren't returning the value to the event
2) you are returning the string "false" instead of the boolean false

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #8
Thanks, this was not the problem. See my reply to VK

--
Arthur, on behalf of Kite Konsultants

"Danny" <da*******@blue bottle.com> wrote in message
news:1121224720 .43ad5d22940ff6 a748c56a48f7a65 572@teranews...

First off, give your page a document type, a DTD, say html4.1 strict dtd
and then validate, chances are your page is malformed and Form is split by
some unclosed opened element in it:

<form> <input> <input> <table> .....</form> </table>
really in quirk mode will cut off the 1st Form at the <table> part as it
never closed IN IT, and more than likely will render a 2nd orphan Form
from the fragment, cutting off any children from the 1st Form. I've seen such and JS does report that because you're eventing an element that's cut
off from the Parent element you think it belongs to.
<FORM> <input> <button> <select></select> <ANYELEMEENT> .....
</ANYELEMENT></form>

is the proper way and will keep all Form children with its parent.
Danny

On Tue, 12 Jul 2005 08:55:13 -0700, Arthur Rusdell-Wilson
<ar****@kitekon sultants.co.uk> wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jul 23 '05 #9

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

Similar topics

18
2882
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
1
4116
by: Dan | last post by:
All, I have a form with a check box on it for which I have implemented a CheckedChange event. The form is the front end of a complex data entry system. When I load the form I check for previously entered data and load that into the form. If a certain value exists then I set the CheckBox Checked property to true. The problem that I have is that, when the form Loads the CheckedChange event fires and that code executes. I don't want that...
0
897
by: Francois Malgreve | last post by:
Hi all, I have a more or less complex form with a few buttons and a few input fields. One of my my input field ( a TextBox) I have an event handler for the TextChanged event. What I want is that when I will hit enter in my input field, I expect to form to be posted back to the server and the event handler for the TextChanged event to be called. If i tabulate from my text field, everythign is working fine. Nevertheless
8
4312
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
1
11574
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
4
1273
by: Lars Netzel | last post by:
Is there any way to add some code that will happen in every single Event that i raised in a form? I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might affect it Is there are was to keep that Filed Total (a value) updated at all time without having to think about it in every single event on the page?
2
2365
by: Robert | last post by:
Hello javascript group readers, I have a question regarding how to prevent memory leaks in Internet Explorer when using closures. I already knew about the circular reference problem, and until now was able to prevent memory leak problems. But I needed to store DOM elements and can't solve it anymore. So I search the group archive to see if I missed any valuable information. I found some interesting articles, but somehow could not apply...
1
1676
by: kaczmar2 | last post by:
I have an ASP.NET page where controls are created dynamically, and I have an issue where one event handler creates another set of controls, and then adds event handlers to those controls. The problem comes in where I need to raise the event in the second control - the event does not fire. I have distilled the example below down to it simplest: on Page_Load one button is created, and a Click event hander is added to the button. When...
10
22370
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi In my app I have a SplashScreen, a login form and a main form. On launching the app, I'd like to show the SplashScreen while reading config files and attempting a database connection. I show progress of these tasks on a label on the SplashScreen form. Once this is completed ok, the splash screen should close and the login form should be displayed. A successful login closes that form and shows the main form.
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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
8870
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
7734
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...
1
6524
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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
4370
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
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 we have to send another system

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.