473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create 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 2064
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="txtWhatever" size="30" />
<INPUT type="submit" onSubmit="return decision()"/>
</FORM>
</HTML>


On target.asp, I just do:

<HTML>
<% Response.Write(Request.Form("txtWhatever")) %>
</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="return decision()"/>


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

<form [...] onsubmit="return 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
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('',...
1
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...
3
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"...
25
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...
3
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...
1
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...
2
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...
8
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
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...
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...
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,...
1
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: 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...
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.