i have got some text boxes and select boxes at the top arranged individually and then a table with about ten columns and 4 rows with provision to add more. a validation is required on submit form that if the first or any of the required field in any row is populated then other required fields must have some value:
for that for that the code is in this way. -1 is the value of sform:elect box when no selection is made just 'Select One'
function onValidation()
if (form.textfield1.value=="-1")
{ alert ("Please give value);
form.textfield1.focus();
return false; //like this for all non tabular field
}
if (form.tablefield1[0].value=="-1")
{ alert ("Please give value);
form.textfield1[0].focus();
return false;
} //like this for the [0] value for all required fields
for (i = 1; i < frm.tablefield1.length; i++)
{
if (form.tablefield1.value != "-1") || (form.tablefield2.value != "")
{
if (form.tablefield1.value=="-1")
{ alert ("Please give value);
form.tablefield1[1].focus();
return false;// like this for all the required fields
}
return true
}
But it does not allow me to submit till i have filled in all the required field in all the visible line though i may not select any column in the 2, 3 0r 4th rows. where is the problem.
also in one of the tabular fields i want a text field be visible if 'any else' is selected in the selection box.
However. i tried with a function 'GeElementByid for the optional block with style display but some how it fails to response. my tabular fieds run run as for num= 1 to rowCnt
and input values are like 'request("tablefield1")(num)'.
Any suggestions
for that for that the code is in this way. -1 is the value of sform:elect box when no selection is made just 'Select One'
function onValidation()
if (form.textfield1.value=="-1")
{ alert ("Please give value);
form.textfield1.focus();
return false; //like this for all non tabular field
}
if (form.tablefield1[0].value=="-1")
{ alert ("Please give value);
form.textfield1[0].focus();
return false;
} //like this for the [0] value for all required fields
for (i = 1; i < frm.tablefield1.length; i++)
{
if (form.tablefield1.value != "-1") || (form.tablefield2.value != "")
{
if (form.tablefield1.value=="-1")
{ alert ("Please give value);
form.tablefield1[1].focus();
return false;// like this for all the required fields
}
return true
}
But it does not allow me to submit till i have filled in all the required field in all the visible line though i may not select any column in the 2, 3 0r 4th rows. where is the problem.
also in one of the tabular fields i want a text field be visible if 'any else' is selected in the selection box.
However. i tried with a function 'GeElementByid for the optional block with style display but some how it fails to response. my tabular fieds run run as for num= 1 to rowCnt
and input values are like 'request("tablefield1")(num)'.
Any suggestions