<script   language="javascript">
<!--
function   CheckForm()
{  
var flag = true;
var allRadio = document.form.elements["a_dzsw"];
for(var i = 0;i < allRadio.length;i++){
   if(allRadio[i].checked==true && allRadio[i].value =="已开展"){
    flag = false;
   }
}
if (!flag){
 alert("请选择")
}
 return flag
}
-->
</script> 这是代码:目前做到的是一个radio如果选择了“已开展”就会弹出个对话框    可是想做到的是 radio选择“已开展”并且另外一个字段填写了数据后就可以提交 ,现在这样的效果是不管另外那个字段是否有数据都会拒绝提交

解决方案 »

  1.   

    另外那个字段,在哪里?是什么TAG?
      

  2.   

    你在方法里再验证那个字段填写了没有 
    如果字段和单选框都符合要求返回true
    否则返回false
    试试
      

  3.   

    我现在已经判断了 name 为a_dzsw的radio   判断了它即满足checked==true 也满足value =="已开展"  这个时候就需要 填写name 为a_qyxxhjh_nd 的text   我判断了radio 可是不会再判断text 怎么判断它们同时满足条件
      

  4.   

    <table width="588" border="0" cellspacing="0" cellpadding="0">
                     <tr>
                       <td width="80" height="24"><input type="radio" name="a_dzsw" value="已开展" <%=checked("已开展",rs("a_dzsw"))%> onclick=hh.style.display='block'>
    已开展 </td>
                       <td width="505"><div id=hh style=display:none>年度:<input type="text" name="a_qyxxhjh_nd" size="12" id="A1" value="<%=rs("a_qyxxhjh_nd")%>"  class="input_on" onfocus="this.className='input_out';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_on'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_on'" />
     
     名称: <input type="text" name="a_qyxxhjh_mc" size="12" value="<%=rs("a_qyxxhjh_mc")%>"  id="A1" class="input_on" onfocus="this.className='input_out';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_on'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_on'" />
     </div></td>
                     </tr>
                     <tr>
                       <td height="24" colspan="2"><input type="radio" name="a_dzsw" value="未开展" <%=checked("未开展",rs("a_dzsw"))%> onclick=hh.style.display='none'>
    未开展 </td>
                     </tr>
                   </table> 这个是代码。。  楼上两位大哥请给小弟指明方向 谢谢
      

  5.   

    试试把下面的方法加到你的代码里:
    // 找出 name 为a_qyxxhjh_nd 的 input, 注意它的id是A1
    var input = document.getElementById("A1");  if ( ... ) {  // 检查 input.value 是否填写了数据
      //todo
    }
      

  6.   

      if(allRadio[i].checked==true && allRadio[i].value =="已开展"){
            //这里获取a_qyxxhjh_nd.text 值
         if(textValue!="") 
               return true  //可以提交
         else 
               return false //不可以提交
       }
    }
    不知道理解的是否正确
      

  7.   

    都10天以前的帖了,是不是该结了?  <table width="588" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="80" height="24">
    <input type="radio" name="a_dzsw" value="已开展" onclick=hh.style.display='block'>
    已开展 
    </td>
    <td width="505">
    <div id=hh style=display:none>
    年度:<input type="text" name="a_qyxxhjh_nd" size="12" id="A1" value=""  class="input_on" onfocus="this.className='input_out';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_on'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_on'" />
    名称: <input type="text" name="a_qyxxhjh_mc" size="12" value="" id="A1" class="input_on" onfocus="this.className='input_out';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_on'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_on'" />
    </div>
    </td>
    </tr>
    <tr>
    <td height="24" colspan="2">
    <input type="radio" name="a_dzsw" value="未开展" checked  onclick=hh.style.display='none'>
    未开展 
    </td>
    </tr>
      </table>
    <INPUT TYPE="button" VALUE=" 提交" ONCLICK="CheckForm()">function   CheckForm()
    {  
    var allRadio = document.getElementsByName("a_dzsw");
    var i;
    for( i = 0; i < allRadio.length; i++) {
    if(allRadio[i].checked && allRadio[i].value =="已开展"){
    //首先,页面元素的 ID 不能够重复
    //这个地方最好用 getElementByID("a_qyxxhjh_nd") 来获取,但是因为上面的原因……
    var nd = document.getElementsByName("a_qyxxhjh_nd")[0];
    //正则表达式控制 年度为空或空格之类的弹提示并选中内容并中断
    var reg = /^\s*$/
    if ( reg.test(nd.value) ) {
    alert("请填写年度");
    nd.select();
    return;
    }
       }
    }
    alert("成功提交!");
    }
      

  8.   

    var a = document.getElementById("A1").value;
    if(a!="" || a!=null)
    {
       //提交
    }