user3302392
user3302392

Reputation: 13

Code to validate radio buttons?

Can any of you supply me with some code that will validate a set of radio buttons, show a confirm box, displaying the selected option to the user, and then proceed or stop based on what the user selects?

Thanks, James

Upvotes: 0

Views: 49

Answers (1)

Awn
Awn

Reputation: 929

var Option Value = document.getElementById('ID').checked;
var Option Value = document.getElementById('ID').checked;
var Option Value = document.getElementById('ID').checked;

if(Option Value == false && Option Value == false && Option Value == false) {
    msg += "You must select an option";
    document.getElementById('ID').style.color="red";
    return false;
}

var selected;
if(Option Value == true) {
    selected = "Option Value";
}
if(Option Value == true) {
    selected = "Option Value";
}
if(Option Value == true) {
    selected = "Option Value";
}

if(Option Value == true || Option Value == true || Option Value == true) {
    var confirmed = confirm("Are you sure you have selected the correct option?" + " You have selected: " + selected)
}

if(confirmed == false) {
    result = false;
}

Hope it helps!

Upvotes: 1

Related Questions