Ok, I have a form that gets validatedwhen submitted, using JavaScript, like so:
<form method="POST" action="confirm.php" name="newuser" onSubmit="return isReady(this)">
The function isReady is in the head section at the top of the same page.
In the form I have three elements, dobD, dobM, dobY that correspond to day, month and year. I want to check if the date entered is valid. The code I have at present is:
<SCRIPT LANGUAGE='JavaScript'>
<!--
function isReady(form)
{
<?php
$datevar = checkdate($dobD,$dobM,$dobY);
if($datevar == 0)
{
echo("alert(\"Incorrect date.\");");
return false;
}
?>
// other javascript validation
}
//-->
</SCRIPT>
I've also tried:
if(<?php checkdate($dobD,$dobM,$dobY); ?>)
{
return true;
}
else
{
alert("Wrong date.");
return false;
}
in the isReady function, but all I get when I run the page is a message saying that the page needs to be debugged at the line above where the <?php tag appears.
So....
Can someone please help me on where to go as I guess I'm doing something dead stupid. Or show me how it should be done...
Cheers,
Paul