473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Why won't this onsubmit action fire?

Hi, I have the following submit code:

<form name="finish" action="Hidden_Birth2.aspx" method="post"
onsubmit="return CheckInput(this);">
<input style="CURSOR: HAND" type="submit" name="finish"
value="FINISH"/>
<b>Click the FINISH button when work instruction is complete.</b>
</form>

and here is my CheckInput script:

function CheckInput()
{
var cnAll = document.all;
for (var i=0;i<cnAll.length;i++)
{
if(cnAll(i).tagName=='input' && cnAll(i).type=='text')
{
alert("You must first complete and SAVE all user inputs!");
return false; }
}
}

....seems to work as far as checking for the elements (type=text), but
if it does not return false; the action of the form (loading the aspx
page) doesn't seem to work. I'm working in asp.net, and I just get a
blank page. Since it is in the hmtl and if the js fails, still can't
figure out HOW to find the problem...since it just quits.

Any help appreciated.

Kathy
Jul 20 '05 #1
1 5062
Ka**********@attbi.com (KathyB) writes:
<form name="finish" action="Hidden_Birth2.aspx" method="post"
onsubmit="return CheckInput(this);">
You send the form to CheckInput as an argument, but doesn't use it.
<input style="CURSOR: HAND" type="submit" name="finish"
value="FINISH"/>
You appear to use XHTML. I would put a space before the final "/>",
just to not confuze older non-XHTML browsers.

The correct CSS for what you want is "cursor:pointer". The "hand" is
an IE invention. For backwards compatability with IE 4, you can use both,
with "hand" last.
function CheckInput()
function CheckInput(form)

(you pass the form anyway)
{
var cnAll = document.all;
for (var i=0;i<cnAll.length;i++)
{
if(cnAll(i).tagName=='input' && cnAll(i).type=='text')
document.all is a collection, so you might want to use it as such, and
not as a function. I.e., "cnAll[i]" instead of "cnAll(i)".
You want to iterate through all the elements of the page and
find the ones that are input elements with type "text". There
are faster ways to do that (especially if you only check inside
the form):

var inputs = (form.getElementsByTagName?
form.getElementsByTagName("input"):
form.all.tags("input")); // for IE 4

for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "text")

{
alert("You must first complete and SAVE all user inputs!");
return false; }
}
}

...seems to work as far as checking for the elements (type=text), but
if it does not return false; the action of the form (loading the aspx
page) doesn't seem to work. I'm working in asp.net, and I just get a
blank page.
So the form *is* submitted, the asp.net just doesn't give the result
you expected. That probably means that the bug is in the asp code.
Since it is in the hmtl and if the js fails, still can't
figure out HOW to find the problem...since it just quits.


You can try making an asp page that displays the form elements
that are submitted, and set the form to point to that page. Then
you can see what is submitted.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

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

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
4
by: Stuart Wexler | last post by:
Hi, I have a form with onSubmit embedded in the <form> tag. The form is submitted programatically through javascript . While the form submits fine, nothing I'm doing seems to get it to...
4
by: Kai Grossjohann | last post by:
I have two frames. Frame "search" contains a search form specifying an onsubmit action like so: <form ... onsubmit="foo();"> ... </form> The other frame contains a <img ......
2
by: Chris | last post by:
I am wondering about what seems to be a particular quirk in Javascript that does not allow form event listeners (e.g. "onsubmit=...") to work properly. In the code below, I would like to set up a...
3
by: iam247 | last post by:
Hi I have an asp page without any javascript. It posts the content of a form to another page, which reads the form fields using Request.Form. This is the form header: <form name=form...
16
by: Rod | last post by:
I can't get this alert to show no matter what I do. Making me crazy. One doesn't equal two...does it? <html> <head> <title>Rider Survey</title> <link rel="stylesheet" type="text/css"...
2
by: memiller | last post by:
I have a hyperlink on an ASP page that calls another ASP page with the code shown below. This page allows (forces) a user to select a file to be uploaded, then should call a third ASP page that...
2
by: GilBates | last post by:
I was kind of expecting to see a "test" message pop up when I clicked the submit button, but NNNNOOOOOOOOOOO! wtf gives? <form method="post" onsubmit="javascript:window.alert('test');"...
2
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as...
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
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...
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
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...
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: 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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.