<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选择“已开展”并且另外一个字段填写了数据后就可以提交 ,现在这样的效果是不管另外那个字段是否有数据都会拒绝提交
<!--
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选择“已开展”并且另外一个字段填写了数据后就可以提交 ,现在这样的效果是不管另外那个字段是否有数据都会拒绝提交
解决方案 »
- 新人请教两个js问题.1-如何能触发一个事件让一个按钮显示出被点击了一下的动画?2-input file透明,用其他按钮遮盖,IE7下点击有光标闪动如何解决?
- js改变Asp.Net控件的名字
- 能不能改变鼠标右键的点击后的菜单显示?
- 在子窗口如何调用父窗口的JAVASCRIPT函数?
- 请问在Javascript中不用ActiveXObject中的Scripting.FileSystemObject控件,还有别的读文件的方法吗?
- 如何做出这个网站的链接效果?
- 关于onload的调用问题,代码如下,不能运行?奇怪!
- 这样的问题难吗?孟老师给个实例好不好
- knockout.js model 更改后为什么view没刷新?
- 遇到了vue子组件的奇怪问题,谁帮我看看
- 关于jquery选择器的问题
- 新人求关注!!高分求高人详解如何解决这个页面让IE浏览器兼容!
如果字段和单选框都符合要求返回true
否则返回false
试试
<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> 这个是代码。。 楼上两位大哥请给小弟指明方向 谢谢
// 找出 name 为a_qyxxhjh_nd 的 input, 注意它的id是A1
var input = document.getElementById("A1"); if ( ... ) { // 检查 input.value 是否填写了数据
//todo
}
//这里获取a_qyxxhjh_nd.text 值
if(textValue!="")
return true //可以提交
else
return false //不可以提交
}
}
不知道理解的是否正确
<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("成功提交!");
}
if(a!="" || a!=null)
{
//提交
}