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

Home Posts Topics Members FAQ

Javascript onSubmit

I am trying to utilize a form to display a message and not submit when
the submit button is clicked, here is an example on what I have done:

<script type="text/javascript">
<!--
function tst()
{
alert('hi');
return false;
}
-->
</script>

<form name=form1 onSubmit=tst();>
.....
....
</form>

When I submit the form, I get the alert message and then the page
refreshes, what I would like is to submit and see the message and then
be returned to the form without having it submit.
Nov 18 '08 #1
2 2908
On 2008-11-18 02:39, tr****@gmail.com wrote:
<form name=form1 onSubmit=tst();>
....
When I submit the form, I get the alert message and then the page
refreshes, what I would like is to submit and see the message and then
be returned to the form without having it submit.
This was just answered here yesterday... Please try to at least read the
subjects of the most recent threads.

You need to:
1) run your HTML through a validator before you start debugging scripts
2) use onsubmit="return tst()"
- Conrad
Nov 18 '08 #2
On Nov 18, 11:39*am, trp...@gmail.com wrote:
I am trying to utilize a form to display a message and not submit when
the submit button is clicked, here is an example on what I have done:

<script type="text/javascript">
<!--
Get rid of the HTML comment demlimiters, they do nothing useful.

function tst()
{
* * * * alert('hi');
* * * * return false;}

-->
</script>

<form name=form1 onSubmit=tst();>
Remember that in-line listeners are bundled into a function and called
by the handler, they must return false to cancel submit, so:

<form ... onsubmit="return tst();">
And don't forget to put quotes around attribute vaules. They aren't
always necessary, but it's a good habit and it is needed here. :-)
--
Rob
Nov 18 '08 #3

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

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
7
by: Michel | last post by:
Hi all, Is there some intelligent way to trigger a clientside JavaScript function before a postback is triggerd by any of the controls on a page? Thanks in advance, Michel Mathijssen
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
by: houstoncity2004 | last post by:
Hi, I need help to JavaScript. I am new to this, and am trying to the page online ASAP. I have two submit buttons on one form, and each button will have to do different things. I named both...
2
by: horos | last post by:
just another thing.. for people who are trying to replace a url outside of a form and who are searching for an answer - when you are trying to use the document.location.replace("") method for going...
2
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ......
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
3
by: jason | last post by:
I have a very simple asp.net 2.0 page with one textbox that onkeyPress is suppose to do some check of what was typed. Below is the source showing the javascript function is available. The minute I...
1
by: tgorton | last post by:
I am having a problem running a javascript function as part of an html-el:form onsubmit. The problem seems to exists in IE6 but not in Firefox. html: <html-el:form action="${target}"...
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...
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,...
0
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...
0
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...
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
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?

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.