2013-01-03 92 views
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> 

单选按钮值将在表格中检索。当我测试了一下,如果没有点击任何选择单选按钮提交按钮,我会得到错误

在功能围棋(),是这样的验证单选按钮是否正确?谢谢

function Go() { 
       if($('form[name=Action] input[name=statusList]:checked').length == 0) 
       { 
        $('form[name=Action]').submit(); 
       } 
       else 
       { 
        alert("Please select at least one to delete"); 
       } 
      } 
+0

你的HTML不会出现任何复选框或输入的。此外,你的JavaScript似乎是倒退的,因为你的条件只在没有检查输入时才提交。此外,Java和异常堆栈跟踪与问题无关。 –

回答

1

使用下面的代码片段

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

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

i相 ' VAR =器isChecked $( '形式[名称=动作]输入[名称= statusList]')测试它是( ':检查'); \t \t \t功能。Go(){ \t \t \t如果(器isChecked!) \t \t \t { \t \t \t \t警报( “请至少选择一个要删除”); \t \t \t \t \t \t \t} \t \t \t别的 \t \t \t { \t \t \t \t $( '形式[名称=动作]')提交(); \t \t \t} \t \t \t} ' 但是,它保持提示警报只要选择了单选按钮或不 – user1944535

+0

请调试它的萤火,让我知道了什么是ü越来越在向器isChecked以及如何价值其余代码的行为我的意思是进入如果块和所有........我想你错过了某些东西在获取特定元素什么是你的id或类名称 – mandava

相关问题