日期:2014-05-17 浏览次数:20738 次
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Untitled Document</title> <script language="javascript"> function sbmt(){ if(fm.user.value==""){ alert("用户名不能为空!"); fm.user.focus(); return false; } else if(fm.pswd.value==""){ alert("密码不能为空!"); fm.pswd.focus(); return false; } else if(fm.checkcode.value==""){ alert("验证码不能为空!"); fm.checkcode.focus(); return false; } fm.submit(); } function checkDate(){ var dat=fm.date.value; var patrn=/^[0-9]{1,20}$/; if(dat.length>0 || patrn.exec(dat)){ var m=dat.split("-"); if( (m[0].length!=4) || (m[1].length!=2) || (m[2].length!=2) || isNaN(m[0]) || isNaN(m[1]) || isNaN(m[2]) || (m[1]>12) || (m[2]>31)){ alert("请按照 YYYY-MM-DD 格式输入日期!"); fm.date.value=""; fm.date.focus(); return false; } } } </script> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <form id="fm" name="fm" method="post" action="test.jsp"> <tr> <td width="24%" align="right">用户名:</td> <td width="76%"><label> <input type="text" name="user" /> </label> </td> </tr> <tr> <td align="right">密码:</td> <td><input type="text" name="pswd" /></td> </tr> <tr> <td align="right">验证码:</td> <td><input type="text" name="checkcode" /></td> </tr> <tr> <td align="right">日期:</td> <td><input type="text" name="date" onblur="checkDate()" /></td> </tr> <tr> <td align="right"> </td> <td><label> <input type="button" name="Submit" value="提交" onclick="return sbmt()" /> </label></td> </tr> </form> </table> </body> </html>