hi,
here is my code for a basic form validation.
the problem occurs when all the validation is fine. an error on the submit line saying the object doesnt support the property or method. i tested it out with an alert and this seems to work alrighty but the submit doesnt like it at all.
<script language="JavaScript">
function validateForm() {
var okSoFar=true //-- Changes to false when bad field found.
//-- Check the Name field, reject if blank.
if (document.myForm.txt_name.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_name.focus()
}
//-- Check the email field, reject if blank.
else if (document.myForm.txt_email.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_email.focus()
}
//-- Check the age field, reject if blank.
else if (document.myForm.txt_age.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_age.focus()
}
//-- Check the Enquiry field, reject if blank.
else if (document.myForm.txt_comment.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_comment.focus()
}
//-- If all fields OK go ahead and submit the form and put up a message.
else if {
//-- The statement below actually submits the form, if all OK.
document.myForm.Submit()
}
}
</script>
cheers in advance
storm
here is my code for a basic form validation.
the problem occurs when all the validation is fine. an error on the submit line saying the object doesnt support the property or method. i tested it out with an alert and this seems to work alrighty but the submit doesnt like it at all.
<script language="JavaScript">
function validateForm() {
var okSoFar=true //-- Changes to false when bad field found.
//-- Check the Name field, reject if blank.
if (document.myForm.txt_name.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_name.focus()
}
//-- Check the email field, reject if blank.
else if (document.myForm.txt_email.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_email.focus()
}
//-- Check the age field, reject if blank.
else if (document.myForm.txt_age.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_age.focus()
}
//-- Check the Enquiry field, reject if blank.
else if (document.myForm.txt_comment.value=="" {
okSoFar=false
alert("All parts of the form must be completed correctly before we can accept an online enquiry."
document.myForm.txt_comment.focus()
}
//-- If all fields OK go ahead and submit the form and put up a message.
else if {
//-- The statement below actually submits the form, if all OK.
document.myForm.Submit()
}
}
</script>
cheers in advance
storm