Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS Validation using onSubmit - where am i going wrong?

Status
Not open for further replies.

garrowsmith

Programmer
Jul 23, 2001
18
GB
I'm doing my nut. Has anyone encountered the netscape bug where it refuses to do anything when using the OnSubmit event handler with a form? I've got a function to validate all the fields within my form, and can't get it to post the data after successful validation.

eg:
...
<script>
function validateForm(){
return true; <- (could document.frm.submit() do it??)
}
</script>
...
<form name=&quot;frm&quot; method=&quot;post&quot; action=&quot;somefile.asp&quot; onSubmit=&quot;return validateForm()&quot;>

I've used the bog standard submit button but it refuses to post to the page in the action field.

Please help!?!

Graham
 
Are you refrencing the ASP file correctly?? Tryu putting a semi-colon after the &quot;return validateForm();&quot;, NS is kinda picky in things like that... I have not failed; I merely found 100,000 different ways of not succeding...
 
Hi GUJU,

here is the complete file. Works fine in IE... what I'm trying to get is a response to the page in NS. I'm not too worried about the file I'm referencing as I just want a response... even if it is 404 file not found.

I tried the semi colon, but no avail. There are loads of sites that state this is the correct way to do things. I've even tried using an onClick=&quot;return validateForm();&quot;>

Any other thoughts?


<html>
<head>
<script>
function validateForm(){
return true;
}
</script>

</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;frm&quot; method=&quot;post&quot; action=&quot;apply_submit.asp&quot; onSubmit=&quot;return validateForm();&quot;>
<input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>
 
LOL, the porblem was simple:
you have <input type=&quot;button&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>

but you need to do this:
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;> I have not failed; I merely found 100,000 different ways of not succeding...
 
Thanks Guju, I'll check it out. I did try that when I was going through every possibilty - but I'll double check.

I have just tried some of the same code on another machine (NN 4.6) and it all seems to work wonderfully. Maybe I have a duff version of NN....

I wish NN was a bit easier to work with! 95% effort for 10% of the audience.....

Cheers,

Graham
 
I've found that if the FORM tag has the method=&quot;POST&quot; then it WILL NOT submit the form in NS4.6 & 4.7. I'm guessing this is a netscape 4.x issue.

There must be some conflict between the method tag and onSubmit. I've removed it and the code seems to work. Anyone know why?

Graham.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top