Discussion Locked

Javascript: Validate Radio Buttons

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Does anyone have a quick script to test if an option of a radio button has been selected?

-Adam

2 replies

by joebevard

If the buttons are named the same you can siple think of them as an array. if this is the button:

you can reference them by this method:
if(document.all.btnAnswer[0].selected) { //"Y" is selected
}
else if(document.all.btnAnswer[1].selected) {
//"N" was selected
}
You're basically checking the selected property to see if it's value is true. Hope this helps!

This discussion is closed to new replies.