<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<script language="javascript" type="text/javascript">
var obj=function(id){return document.getElementById?document.getElementById(id):id};
function checkp(){
if(obj('title').value.length<5){
alert("标题不能少于5个字符");
obj('title').focus();
return false;
}
if(obj('user').value==""){
alert("用户名不能为空")
obj('user').focus();
return false;
}
if(obj('content').value==""){
alert("内容不能为空");
obj('content').focus();
return false;
}
if(obj('boy').checked==""&&obj('girl').checked==""){
alert("男女单选没有做选择!");
obj('boy').focus();
return false;
}
var year=parseInt(obj('year').value);
if((year%4==0&&year%100!=0)||year%400==0)
{
var two=28; //判断是否润年,如果2月为是28天;
}
else
{
var two=29;
//不是闰年所以为29天!
}
var mm=parseInt(obj('months').value);
switch (mm)
{
case 2:if(obj('day').value>two){alert('2月超过了实际天数!');obj('day').focus();return false;}break
case 4:
case 6:
case 9:
case 11:
if(obj('day').value>30){alert('当月超过了实际天数!');obj('day').focus();return false;}break
};
}
</script>
<div id="right">
<form action="kk.htm" method="post" name="myform" onsubmit="return checkp();">
<br /><br />
<span>标题</span>:<input type="text" name="title" id="title" value="12345" /><br />
<span>用户</span>:<input type="text" name="user" id="user" value="12345" /><br />
<span>内容</span>:<textarea name="content" id="content" value="">12345</textarea><br />
男
<input type="radio" name="sex"
id="boy" value="male" checked="checked"/><br />
女
<input type="radio" name="sex"
id="girl" value="female" /> <br />
出生年月:
<select name="year" id="year"><br />
<option selected="selected" value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
<option value="1993">1993</option>
<option value="1994">1994</option>
<option value="1995">1995</option>
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
</select>
年
<select name="months" id="months">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
月
<select name="day" id="day">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<br />
<input type="submit" name="submit" id="sub" value="发表留言">
</form>
</div>
<div id="left1"></div>
<div id="left2"></div>
<div id="left3"></div>
<div id="left4"></div>
<div id="foot"></div>
</body>
</html>
参考一下: