473,545 Members | 289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When is onSubmit fired?

When does the onSubmit event occur? When does the JavaScript code we
write in this event get executed?

a. Before a page is posted to the server?
b. After the page is posted back, if posted back to itself, and
recieved from the server?

Apr 18 '06 #1
5 2067
Sorry. Please ignore this question.

Apr 18 '06 #2
OK, I am confused. I asked this question because the JavaScript
tutorial on w3schools says that onSubmit will cancel the submission if
the code it executes returns a value false. To test, I did this and yet
the page got posted to the target page successfully.
<HTML>
<SCRIPT>
function decision()
{
return false;
}
</SCRIPT>

<FORM name="frm" action="http://localhost/JavaScript/target.asp"
method="POST">
<INPUT type="text" name="txtWhatev er" size="30" />
<INPUT type="submit" onSubmit="retur n decision()"/>
</FORM>
</HTML>


On target.asp, I just do:

<HTML>
<% Response.Write( Request.Form("t xtWhatever")) %>
</HTML>

Apr 18 '06 #3

Water Cooler v2 wrote:
OK, I am confused. I asked this question because the JavaScript
tutorial on w3schools says that onSubmit will cancel the submission if
the code it executes returns a value false. To test, I did this and yet
the page got posted to the target page successfully.

[snip]
<INPUT type="submit" onSubmit="retur n decision()"/>


The function must be attached to the event of the FORM, not the submit
button.

<form [...] onsubmit="retur n decision()">

Apr 18 '06 #4
Thanks very much, Ronaldo.

Apr 18 '06 #5
Thanks, Lee. I got that.

Apr 18 '06 #6

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

Similar topics

3
24518
by: jeff | last post by:
Hello, I have a form that submits it's values to a pop-up window. I've simplied the code: <form name="formname" action="action.php" target="windowName" method="post" onsubmit="window.open('', this.target, 'dialog,modal,scrollbars=yes,resizable=no,width=300,height=200,left=362,top=284');">
1
1934
by: Robert Nurse | last post by:
Hi All, I'm trying to create a text field that, when two or more characters are entered, the form is automatically submitted. The trouble I'm having is knowing when the onSubmit handler is fired. It's supposed to be executed when the form is submitted. I'm doing a submit via JS which should cause the form to run the onSubmit handler. ...
3
12126
by: n3mtkj3mzsir0cy | last post by:
I have created web pages that do client-side form validation using the onclick directive. E.g., <form action=other_page.cgi method=post> Enter your age: <input name=age> <input type="submit" value="" onclick="return validate_form()"> </form> where validate_form() returns true or false depending on whether the user entered a valid age.
25
17155
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from being uploaded. I'm also using the HtmlInputFile control to do the uploading. My problem is that when the user's file size exceeds 512k, the page...
3
1872
by: Taras_96 | last post by:
Hi everyone, I've got a rather unconventional architecture that I'm having problems with... I have a form called "searchForm", that has an input of type "submit" (with name = "submitButton for argument sake). What happens when the form is submitted (when the submit button is clicked...) depends on some previous user input. In one case,...
1
4760
by: APA | last post by:
Well, I've figured out a way around this mess. I have no idea why it doesn't work the way I think it should but I do know how to get it to work. The scenario is that I have a form that has one submit button on it. I want a client side validation function to run before submit. I have a server side event handler on the button that executes the...
2
2061
by: William Cole | last post by:
Here is my issue I have two text fields (Field A, Field B). I want Field B to be updated when Field A is changed. The problem is Field A is being changed through JavaScript so an onChange event is not fired. Is there any way to make this work without having to change the code that changes Field A? Thanks, William
8
6834
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
1
1932
by: vunet | last post by:
I write a JS library component which is applied to every form on a webpage. The component does something before it submits the form. Now, let's say user has his own onSubmit() handlers returning true or false. I want to find a way to add my component's "onsubmit" event to the form without overwriting user-defined onSubmit() handlers or...
0
7805
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
7416
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
5969
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...
1
5325
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...
0
4944
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
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
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
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
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.