Javascript 如果未选择单选按钮,则显示警报()

Javascript 如果未选择单选按钮,则显示警报(),javascript,radio-button,Javascript,Radio Button,单击“删除”按钮后,如果未选择任何单选按钮,如何显示警报。我的html表单 <form name="Action" method="post" action="RequestAction"> <table width="800px" cellpadding="5" style="color:black; border-top:1px solid #ccc;" border="0"> </

单击“删除”按钮后,如果未选择任何单选按钮,如何显示警报。我的html表单

<form name="Action" method="post" action="RequestAction">
                    <table width="800px" cellpadding="5" style="color:black; border-top:1px solid #ccc;" border="0">
                    </table>
                    <div id="container">
                    <div id="demo_jui">
                    <table id="requestList" class="display" cellpadding="0" cellspacing="0" border="0" style="font-size:12px;" >
                    <thead id="headed">
                        <tr>
                            <th  align="center" title="Employee">Employee</th>
                            <th  align="center" title="Number of Days">Number of Days</th>
                            <th  align="center" title="Start Date">Start Date</th>
                            <th  align="center" title="End Date">End Date</th>
                            <th  align="center" title="Leave Type">Leave Type</th>
                            <th  align="center" title="Remark">Remark</th>
                            <th  align="center">Approve</th>
                            <th  align="center">Reject</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                    </table>
                    </div>
                    </div>
                        <table>                 
                        <tr>
                            <td style="padding-left:0px;" colspan="3">
                                <a href="#"><img src="images/Submit.png" style="border:none;" onClick="javascript:Go()"
                                onmouseover="this.src='images/Submit_Hover.png'" onmouseout="this.src='images/Submit.png'"/></a>
                                &nbsp;&nbsp;&nbsp;
                                <a href="#"><img src="images/Reset.png" style="border:none;" onClick="javascript:clearForm()"
                                onmouseover="this.src='images/Reset_Hover.png'" onmouseout="this.src='images/Reset.png'"/></a>
                            </td>
                        </tr>
                    </table>
                </form>
也许检查“已检查”状态不起作用

//read value of radio button
alert($("input[name='radio-button-group']:checked").val());

//get bool, if radio button is checked
alert(typeof $("input[name='radio-button-group']:checked").val() != 'undefined');
来源(德语):

可能检查“已检查”状态不起作用

//read value of radio button
alert($("input[name='radio-button-group']:checked").val());

//get bool, if radio button is checked
alert(typeof $("input[name='radio-button-group']:checked").val() != 'undefined');
来源(德语):

使用以下代码片段

var IsChecked = $('take id or classname of radiogroup').is(':checked');

if(!IsChecked)
{
alert("select some thing");
}
使用下面的代码片段

var IsChecked = $('take id or classname of radiogroup').is(':checked');

if(!IsChecked)
{
alert("select some thing");
}

您的HTML似乎根本没有任何复选框或输入。此外,您的JavaScript似乎是向后的,因为您的条件仅在没有选中输入的情况下提交。此外,Java和异常堆栈跟踪与问题无关。HTML似乎根本没有任何复选框或输入。此外,您的JavaScript似乎是向后的,因为您的条件仅在没有选中输入的情况下提交。另外,Java和异常堆栈跟踪与问题无关。我使用“var IsChecked=$(“form[name=Action]input[name=statusList]”)测试它。is(“:checked”);函数Go(){if(!IsChecked){alert(“请至少选择一个要删除”);}其他{$('form[name=Action]')。submit();}}`但是,无论何时选择或不选择单选按钮,它都会保持提示警报请在firebug中调试它,并让我知道您要检查的值是什么,以及其余代码的行为如何我的意思是输入if块和所有……。我认为您在获取特定元素时遗漏了一些内容您正在使用的id或类名是什么进行测试`var IsChecked=$('form[name=Action]input[name=statusList]')。是(':checked');函数Go(){if(!IsChecked){alert(“请至少选择一个要删除”);}其他{$('form[name=Action]')。submit();}}`但是,无论何时选择或不选择单选按钮,它都会保持提示警报请在firebug中调试它,并让我知道您要检查的值是什么,以及其余代码的行为如何我的意思是输入if块和所有……。我认为您在获取特定元素时遗漏了某些内容您拥有的id或类名是什么