I just learned to write Javascript. the following is some code used to validate 9 fields in a form. However, the code does not work. I think the problem is where I try to refer to all textboxes in the form - theform.elements["txtex" + i]. What should I do?
****
function DataValidation(theForm)
{
var i
// alert("All expense field must be entered."
;
for (i=1; i<10; i=i+1)
{
if (theform.elements["txtex" + i]==""
{
alert("All expense field must be entered."
;
return (false);
}
}
return (true);
}
****
I tried to call this function from the following code.
****
<FORM METHOD="Post" ACTION="view.ASP" name="frmBudget" onsubmit="return DataValidation(this)">
****
Thanks in advance.
Seaport
****
function DataValidation(theForm)
{
var i
// alert("All expense field must be entered."
for (i=1; i<10; i=i+1)
{
if (theform.elements["txtex" + i]==""
{
alert("All expense field must be entered."
return (false);
}
}
return (true);
}
****
I tried to call this function from the following code.
****
<FORM METHOD="Post" ACTION="view.ASP" name="frmBudget" onsubmit="return DataValidation(this)">
****
Thanks in advance.
Seaport