我正在尝试验证 JavaScript 中的单选按钮,这是我的代码:
if (document.ExamEntry.GCSE.checked == true) {
confirm("You have selected GCSE. Is this correct?");
}
if (document.ExamEntry.AS.checked == true) {
confirm("You have selected AS. Is this correct?");
}
if (document.ExamEntry.A2.checked == true) {
confirm("You have selected A2. Is this correct?");
}
确认窗口出现并单击“提交”成功将您带到下一页,但是取消按钮似乎不起作用 - 当我希望它留在页面上时它只会将您带到下一页以便您可以更改你的选择。
我已经尝试过诸如返回结果之类的东西;结果=假
它们要么不起作用,要么如果起作用,则反之亦然,因此取消按钮通过停留在同一页面上起作用,但提交按钮也会发生这种情况。