Skip to main content
Known Participant
June 20, 2008
Question

A little java help

  • June 20, 2008
  • 1 reply
  • 200 views
I have a form where I dynamically generate ten checkboxes.

If the seventh box is checked, then I need to make one of the input fields required.

I have something like this (lots of variations) but it will not work :

if (formname.checkbox_id["7"].checked && formname.comments.value == "")
{
alert ("Comments are required.");
formname.comments.focus();
returnStatus(false);
}

How do I do this ? thanks
    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    June 21, 2008
    I think it is better to put focus on the comments field anyway. In the following example, I have assumed that your intention is to make the form submittable in every case, except where checkbox 7 is checked and the comments field is empty.