JS怎么判断select是否选中,未选中提醒。
<SCRIPT>$(function(){$("#next").click(function(){$(".warn").text("");$(".warn").hide(...
<SCRIPT>
$(function(){
$("#next").click(function(){
$(".warn").text("");
$(".warn").hide();
var cnName=$("#cnName").val();
if(cnName==""){
$(".warn").text("请您输入姓名。");
$(".warn").show();
return false;
}else if(!fivekey_validate_username()){
$(".warn").text("姓名不符合规范,请您重新输入。");
$(".warn").show();
return false;
};
$("#form1").submit();
});
});
</SCRIPT>
<DL><INPUT type="text" onKeyUp="this.value=this.value.replace(/^ +| +$/g,'')" id=cnName class=input1
name=cnName></DL></SECTION>
<SECTION><SPAN>有效期</SPAN>
<DL>
<select id="shouji" name="sja">
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select> <select id="shouji" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
</select> <span id="dateErr" class="formErr"></span></DL> 展开
$(function(){
$("#next").click(function(){
$(".warn").text("");
$(".warn").hide();
var cnName=$("#cnName").val();
if(cnName==""){
$(".warn").text("请您输入姓名。");
$(".warn").show();
return false;
}else if(!fivekey_validate_username()){
$(".warn").text("姓名不符合规范,请您重新输入。");
$(".warn").show();
return false;
};
$("#form1").submit();
});
});
</SCRIPT>
<DL><INPUT type="text" onKeyUp="this.value=this.value.replace(/^ +| +$/g,'')" id=cnName class=input1
name=cnName></DL></SECTION>
<SECTION><SPAN>有效期</SPAN>
<DL>
<select id="shouji" name="sja">
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select> <select id="shouji" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
</select> <span id="dateErr" class="formErr"></span></DL> 展开
1个回答
推荐于2016-02-22
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8>
<title>recursion</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$ (function ()
{
$ ("#next").click (function ()
{
if ($('select[name="sja"]').val() == '0')
{
alert('请选择月份!');
return false;
}
else if ($('select[name="sjb"]').val() == '0')
{
alert('请选择年份!');
return false;
}
$ ("#form1").submit ();
});
});
</script>
</head>
<body>
<SECTION>
<DL>
<INPUT type="text" onkeyup="this.value=this.value.replace(/^\s+|\s+$/g,'')" id=cnName class=input1 name=cnName>
</DL>
</SECTION>
<SECTION>
<SPAN>有效期</SPAN>
<DL>
<select id="shouji" name="sja">
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="shouji" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>
<span id="dateErr" class="formErr"></span>
</DL>
<input type="button" value="next" id="next" />
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询