Click here to Skip to main content
15,884,836 members

Response to: display alert when radio button is not selected

Revision 2
C#
function radiobuttonchecking( ) {
          var tableID ='<%= RadioBtn.ClientID %>';

          var radioButtons = $(tableID).find(':input')
          var totalRows = radioButtons.length;
          var radioButton;
          var flagRadioButtonChecked = false;
          for (var rowIndex = 0; rowIndex < totalRows; rowIndex++) {
              radioButton = radioButtons[rowIndex]
              //Check if it's a radio button
              if (radioButton.type == 'radio') {
                  //Check if it's checked
                  if (radioButton.checked) {
                      //current radio button is checked
                      flagRadioButtonChecked = true;
                      //breaking from here will keep reference of checked radio button to radioButton variable
                      break;
                  }
              }
          }

XML
//Check if any radio button is checked
       if(flagRadioButtonChecked)
       {
           alert(radioButton.value + ' is checked...');
       }
   }
   </script>



its working in my application
Posted 11-Oct-12 4:53am by Dheeraj Kumar Pentela.
  Print Answers RSS
Top Experts
Last 24hrsThis month