I'm trying to figure out why this function isn't being called after the form is submitted. The "checkForm()" JS function works fine when the form is submitted, but I can't seem to get the checkDates() function working. I tried moving it above the PHP code and no alert message showed up. Any help is greatly appreciated, thank you!
Here's the pseudo code version of my file:
<?php
if(isset($_POST['next'])){
// Some PHP code
echo "<script> checkDates(); </script>";
}
?>
<form name="form1" id="form1" method="post" action="<?php print $thispage;?>" onsubmit="return checkForm()">
// Some HTML code
</form>
<script>
var isDateTimeValid = true;
function checkDates() {
alert("Hello");
isDateTimeValid = false;
}
function checkForm () {
if (isDateTimeValid == true) {
return true;
}
else {
return false;
}
}
</script>