Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

A little java help

New Here ,
Jun 19, 2008 Jun 19, 2008
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
182
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 21, 2008 Jun 21, 2008
LATEST
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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources