日期:2014-05-16  浏览次数:20339 次

关于屏蔽提交键的JS
我想实现下拉菜单如果不是选择1就不能提交,请问用JS如何实现?谢谢!
<select   name= "lb "   id= "lb ">
<option   value= "1 "> 1 </option>
<option   value= "2 "> 2 </option>
<option   value= "3 "> 3 </option>
</select>
<input   id= "b1 "   type= "submit "   value= "提交 ">

------解决方案--------------------
<script type= "text/javascript ">
var cs = function (o) {
return o.lb.options[o.lb.selectedIndex].value != "1 ";
};
</script>
<form action= "? " method= "get ">
<select name= "lb " id= "lb ">
<option value= "1 "> 1 </option>
<option value= "2 "> 2 </option>
<option value= "3 "> 3 </option>
</select>
<input id= "b1 " type= "submit " value= "提交 " onclick= "return cs(this.form) ">
</form>
------解决方案--------------------
<form name=frm>
<select name= "lb " id= "lb " onchange= "javascript:chg(); ">
<option value= "1 " > 1 </option>
<option value= "2 " > 2 </option>
<option value= "3 " > 3 </option>
</select>
<input id= "b1 " type= "submit " value= "提交 ">
</form>
<script language=javascript>
function chg(){
if(document.frm.lb.value!=1){
document.frm.b1.disabled= "true ";
}else{
document.frm.b1.disabled= " ";
}
}
</script>