Manage Learn to apply best practices and optimize your operations.

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;
   }
}

Dig Deeper on J2EE for Lotus Notes Domino and WebSphere

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close