I have a php page that posts to itself to add records to a DB. In the form tag, I have a 'onSubmit="return CheckForm()"', which should be running prior to the form posting. Below is my CheckForm() function, which is not working. The form just goes ahead and posts itself, and adds the blank record to the database. Any suggestions or help would be greatly appreciated.
Again, thank you for any help given!
Code:
<script type="text/javascript" language="javascript">
<!--
function CheckForm(){
var tmpError = "Missing Information:"
var tmpPNF = document.PreKSurvey.frmPrntName_First.value
var tmpPNL = document.PreKSurvey.frmPrntName_Lastt.value
var tmpAD1 = document.PreKSurvey.frmAddr_1.value
var tmpADC = document.PreKSurvey.frmAddr_City.value
var tmpADS = document.PreKSurvey.frmAddr_St.value
var tmpADZ = document.PreKSurvey.frmAddr_Zip.value
var tmpCNF = document.PreKSurvey.frmChldName_First.value
var tmpCNL = document.PreKSurvey.frmChldName_Last.value
var tmpCK8 = document.PreKSurvey.frmCheck_8.value
var tmpC8T = document.PreKSurvey.frmCheck_8_Txt.value
if(tmpPNF == ""){tmpError += "\nPlease fill out 'Parent First Name'."}
if(tmpPNL == ""){tmpError += "\nPlease fill out 'Parent Last Name'."}
if(tmpCNF == ""){tmpError += "\nPlease fill out 'Child First Name'."}
if(tmpCNL == ""){tmpError += "\nPlease fill out 'Child Last Name'."}
if(tmpAD1 == ""){tmpError += "\nPlease fill out 'Address 1'."}
if(tmpADC == ""){tmpError += "\nPlease fill out 'Address City'."}
if(tmpADS == ""){tmpError += "\nPlease fill out 'Address State (2 letter code)'."}
if(tmpADZ == ""){tmpError += "\nPlease fill out 'Address Zip'."}
if(tmpCK8 == "on" && tmpC8T == ""){tmpError += "\nPlease fill out 'Diagnosis'."}
if(tmpError == "Missing Information:"){return true} else {alert(tmpError); return false;}
}
-->
</script>
Again, thank you for any help given!