I would like to make sure the user selects a radio button. (as in a Yes, No set) By default none of the buttons are selected. if (strMedical == '') or if (strMedical == 'No'), etc. doesn’t respond. Is there a way to check if a button in a set has been selected and pop up a message if none of the buttons were selected?
Radio buttons have a "checked" parameter. If the button is selected, it's "checked" parameter is true, otherwise it is false. So use the following syntax:
if (!document.formName.strMedical.checked) // not checked
Thanks, Gil. I was able to get that working for checkboxes, but it doesn't seem to work on radio buttons. It returns as unchecked no matter what. Is there a different paramiter that is used by radio buttons?
Yes, you were right. When there's more than one button in a set it's an array. I just added the [0] and [1] at the end and now I can detect Yes and No selections. Thanks for the link the to javascript docs. That will be a big help.
Bookmarks