如何使用js控制form表单中的select标签?
1个回答
展开全部
<form id="myform" >
<select name="month" id="month">
<option value="" selected="selected">请选择</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03" >March</option>
<option value="04">April</option>
</select>
<input type="submit" />
</form>
<script language="javascript">
<!--
var myForm = document.getElementById("myform");
var slct = document.getElementById("month");
function check()
{
alert(!!slct.value);
if(!slct.value){ alert("请选择"); return false}else{ return true;}
}
myForm.onsubmit=function (){return check();}
-->
</script>
<select name="month" id="month">
<option value="" selected="selected">请选择</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03" >March</option>
<option value="04">April</option>
</select>
<input type="submit" />
</form>
<script language="javascript">
<!--
var myForm = document.getElementById("myform");
var slct = document.getElementById("month");
function check()
{
alert(!!slct.value);
if(!slct.value){ alert("请选择"); return false}else{ return true;}
}
myForm.onsubmit=function (){return check();}
-->
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询