Hi,
I have a form which includes a field 'number'. When 'number' is changed
additional fields ('item_0', etc) are generated on the form using
'onchange'.
I want to validate the form using Javascript before submission.
I've set out the part of the validation script used to loop through the
dynamically generated fields below. This is where I am encountering
problems.
The script works fine so long as all the dynamically generated fields
are blank. If any of the dynamically generated fields contains data the
script treats the whole form as validated even if all the other fields
are blank.
I've tried lots of different changes to get it to works without
success. I'd appreciate any suggestions as to what's going wrong.
With regards
Emmett Power
//////////////////////Script extract////////////////////////////
var fval = parseInt(number);
for(var i = 0; i < fval; i++) {
var e = eval('document.myForm.item_'+i);
if ((e.value == null) || (e.value == "") || isblank(e.value)) {
{errormsg = errormsg + " - The field for item " + (i+1) + " is
blank.\n";}
submitOK="False"
}
}
if (submitOK=="False")
{
alert("I am sorry but you need to provide a little more information
in order to proceed. The following items need to be completed:\n\n" +
errormsg)
return false
}
//////////////////////Script extract end/////////////////////////