function call on submit

R

Ron Eggler

Hi,

I have a function call in my form tag like this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
name="myform" id="myform" onsubmit="return chkform()">

and the function looks like:
<script type="text/javascript">
function chkform()
{
if (document.myform.first_name.value == "")
{
alert("Please enter your firstname!");
document.Formular.first_name.focus();
return false;
}
if (document.myform.last_name.value == "")
{
alert("Please enter your lastname!");
document.Formular.last_name.focus();
return false;
}
....
....
....
alert("SUBMIT!");
return true;
}
</script>

It can be checked out here: http://www.dvdnowkiosks.com/tmp/form.php
The form gets submitted even tho the function returns false, why this??? :eek:
As soon as you hit the OK button from the alert box, data get submitted to
the php, why this? It shouldn't, no? What am i doing wrongly?

Thank you!
Ron
 
L

Lee

Ron Eggler said:
Hi,

I have a function call in my form tag like this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
name="myform" id="myform" onsubmit="return chkform()">

and the function looks like:
<script type="text/javascript">
function chkform()
{
if (document.myform.first_name.value == "")
{
alert("Please enter your firstname!");
document.Formular.first_name.focus();

What is "document.Formular"?
Shouldn't that (and similar references) be "document.myform" ?

(Disregarding the questionableness of using fully qualified
form references, rather than passing a reference to the
function)


--
 
R

Ron Eggler

Lee said:
Ron Eggler said:
Hi,

I have a function call in my form tag like this:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
name="myform" id="myform" onsubmit="return chkform()">

and the function looks like:
<script type="text/javascript">
function chkform()
{
if (document.myform.first_name.value == "")
{
alert("Please enter your firstname!");
document.Formular.first_name.focus();

What is "document.Formular"?
Shouldn't that (and similar references) be "document.myform" ?

(Disregarding the questionableness of using fully qualified
form references, rather than passing a reference to the
function)


--

This actually fixed it... Omg......
Thanks for the hint! :)
Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top