runcsmeduncs
Programmer
Hello
I am fairly new to JavaScript so bare with me on this one.
My function looks like this:
<script language="JavaScript" type="text/JavaScript">
function checkForm(theForm){
box1 = frmHR.p_update;
box2 = frmHR.p_hr_update;
if(frmHR.p_update.length){
for (i=0;i<box1.length;i++){
if (box1.checked && box2.checked){
alert("You cannot select both");
box1.focus();
return false;
}
}
}
else
{
if (box1.checked && box2.checked){
alert("You cannot select both");
return false;
}
}
return true;
}
</script>
very simply all it does is a bit of validation on my form which has 20 rows. 1 or many of the rows can contain 2 checkboxes "p_update" and "p_hr_update". This check just makes sure that the user cannot check them both.
My function works fine when there is one or more rows containing these checkboxes on the form but generates an error when there are no rows on the form with the 2 checkboxes.
All i am trying to do is modify the function to return true when there are no checkboxes on the form with the name "p_update" and p_hr_update".
Hope someone can help.
Regards
Duncan
I am fairly new to JavaScript so bare with me on this one.
My function looks like this:
<script language="JavaScript" type="text/JavaScript">
function checkForm(theForm){
box1 = frmHR.p_update;
box2 = frmHR.p_hr_update;
if(frmHR.p_update.length){
for (i=0;i<box1.length;i++){
if (box1.checked && box2.checked){
alert("You cannot select both");
box1.focus();
return false;
}
}
}
else
{
if (box1.checked && box2.checked){
alert("You cannot select both");
return false;
}
}
return true;
}
</script>
very simply all it does is a bit of validation on my form which has 20 rows. 1 or many of the rows can contain 2 checkboxes "p_update" and "p_hr_update". This check just makes sure that the user cannot check them both.
My function works fine when there is one or more rows containing these checkboxes on the form but generates an error when there are no rows on the form with the 2 checkboxes.
All i am trying to do is modify the function to return true when there are no checkboxes on the form with the name "p_update" and p_hr_update".
Hope someone can help.
Regards
Duncan