Form Validation Not Working
Posted: Mon Jun 21, 2010 4:08 pm
It is strange that this form validation function is not working as expected:
This is how I am using it in the Form Tag:
When the form is valid then the function does display the message:
but then nothing happens. The application as specified in:
is not called at all. The form remains there as it is.
If I remove "return false" from:
then the form is submitted whether it is valid or not.
I have used the same method before and it is working fine. Where is the mistake? Any help?
Code: Select all
function Validate() {
var tbl = document.getElementById("tblCalls");
var noRows = tbl.tBodies[0].rows.length;
var NotC2Tckt = eval(document.VCT.NotC2Tckt.value);
if (NotC2Tckt > 0 && noRows < 1) {
alert("Add Rows and Provide Information as the value of 'Not Converted to HD Tickets' is greater than 0.");
return false;
}
else {
alert("All is fine! Submitting");
return true;
}
}This is how I am using it in the Form Tag:
Code: Select all
<form name="VCT" action="savevoiceCT.php" method="post" onsubmit="Validate(); return false;" language="jscript">Code: Select all
alert("All is fine! Submitting");but then nothing happens. The application as specified in:
Code: Select all
action="savevoiceCT.php" If I remove "return false" from:
Code: Select all
onsubmit="Validate(); return false;" I have used the same method before and it is working fine. Where is the mistake? Any help?