用于验证单选按钮的代码?

时间:2014-02-12 16:38:23

标签: validation

您是否可以向我提供一些代码,这些代码将验证一组单选按钮,显示确认框,向用户显示所选选项,然后根据用户选择的内容继续或停止?

谢谢, 詹姆斯

1 个答案:

答案 0 :(得分:1)

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

希望它有所帮助!