Hi, Heres the code, its called by passing is a list of fields to check for, idea being that it'll be called and the fields can be passed dynamically.
Theres a few alerts used for debugging
var theForm = document.forms.ClaimForm;
function CheckForm(FieldList)
{
var error = false;
//this works if we use the full name off the form element rather than the
element array id ie i in the for loop
alert("this many radios " + theForm.elements["WorkStatus"].length)
for (var i=0; i < theForm.elements.length; i++)
{
//see if the form element we are on is one that we want to check -
passed in FieldList
if (FieldList.indexOf(theForm.elements[i].name) != -1)
{
//we've found a field that we want to check
//now we need to detect its type and process it accordingly
switch (theForm.elements[i].type)
{
case "radio":
//WHY DOESN"T THIS WORK!!????
//alert(theForm.elements[i].length);
alert(i);
if (theForm.elements[i].checked == false)
{
error = true;
alert(theForm.elements[i].name);
}
break;
case "text":
if (theForm.elements[i].value == '')
{
error = true;
alert(theForm.elements[i].name);
}
break;
case "checkbox":
if (theForm.elements[i].checked == false)
{
error = true;
alert(theForm.elements[i].name);
}
break;
case "select-one":
if (theForm.elements[i].value == '')
{
error = true;
alert(theForm.elements[i].name);
}
break;
}
}
}
alert(error);
}
Paul Broomfield
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
