Validating radio button fields

I have created this generic function to check if a value of a radio button field has been selected.

I have created this generic function to check if a value of a radio button field has been selected.

The code for a multiple option field is different to a single option field because field.length for a single option is 'undefined' and not '1' as would be expected so I have initially tested if field.length == null


function RadioOptionSelected(fldRadioToCheck)
{
   //returns whether the user has made a choice in a radio button group

  if (fldRadioToCheck.length == null)  //only one option 
  {
     if (fldRadioToCheck.checked)
     {
       return true;
     }
     else
     {
       return false;
     } 
   } 
   else  //multiple options
   {
     for (intRadioOption = 0; intRadioOption < fldRadioToCheck.length ; intRadioOption++)
     {
       if (fldRadioToCheck[intRadioOption].checked == '1')    
       {
         return true;
       }       
     }
     return false;
   }
}
This was last published in November 2001

Dig Deeper on J2EE for Lotus Notes Domino and WebSphere

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close