I am attempting to validate an ASP page using client-side javascript (so that I do not lose the data entered into the form). The validation is dynamic, as I never know how many rows will be returned in the ASP, the code looks like this:
function validateForm1(p_object)
{
for (eval("x=0;x<="+p_object+";x++"))
{
if(eval("document.form1.pod"+x+"_delstatus.value != "";"))
{
if(eval("document.form1.pod"+x+"_itemcount.value == "";"))
{
(eval("document.form1.pod"+x+"_itemcount.focus()"));
alert("You must enter an item count for this record");
return false;
}
if(eval("document.form1.pod"+x+"_deltime.value == "";"))
{
(eval("document.form1.pod"+x+"_deltime.focus()"));
alert("You must enter a delivery time for this record");
return false;
}
if(eval("document.form1.pod"+x+"_signature.value == "";"))
{
(eval("document.form1.pod"+x+"_signature.focus()"));
alert("You must enter an signatory name for this record");
return false;
}
}
}
}
The variable 'p_object' is a number.
When I attempt to run this function I get a generic Jscript error (Error: Expected ';') which hasn't helped me as I've gone through the code carefully and found no missing semi-colons or other errors I can find.
Can anyone help me? Thanks in advance.
Ben
function validateForm1(p_object)
{
for (eval("x=0;x<="+p_object+";x++"))
{
if(eval("document.form1.pod"+x+"_delstatus.value != "";"))
{
if(eval("document.form1.pod"+x+"_itemcount.value == "";"))
{
(eval("document.form1.pod"+x+"_itemcount.focus()"));
alert("You must enter an item count for this record");
return false;
}
if(eval("document.form1.pod"+x+"_deltime.value == "";"))
{
(eval("document.form1.pod"+x+"_deltime.focus()"));
alert("You must enter a delivery time for this record");
return false;
}
if(eval("document.form1.pod"+x+"_signature.value == "";"))
{
(eval("document.form1.pod"+x+"_signature.focus()"));
alert("You must enter an signatory name for this record");
return false;
}
}
}
}
The variable 'p_object' is a number.
When I attempt to run this function I get a generic Jscript error (Error: Expected ';') which hasn't helped me as I've gone through the code carefully and found no missing semi-colons or other errors I can find.
Can anyone help me? Thanks in advance.
Ben