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 first published in November 2001

Dig deeper on J2EE for Lotus Notes Domino and WebSphere

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-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