我怎么去有没事的时候选中此不提交,但随后有当一个人被选中提交? 目前,它提交两种方式。 我缺少的是在这里吗? 它抛出了我希望它没事的时候被检查到的错误“请检查上面的选项之一”,但然后进入登陆页面。 感谢您的任何帮助!
$(document).ready(function () {
$("#submitbutton").click(function () {
var none_answered = true;
$("input:radio").each(function () {
var name = $(this).attr("name");
if ($("input:radio[name]:checked").length == 0) {
none_answered = false;
}
});
if (none_answered == false) {
$('#texthere').html("Please check one of the options above");
}
})
});
<style type="text/css">
#texthere
{
color:red;
}
</style>
<body>
<form>
<input type="radio" name="refer" value="Strategic Communication" >Strategic Communication</br>
<input type="radio" name="refer" value="Journalism" >Journalism</br>
<input type="radio" name="refer" value="Communication Studies" >Communication Studies</br>
<div id="texthere"></div>
<input id="submitbutton" type="submit" value="submit" formaction="http://www.utah.edu/">
</form>
</body>