<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<TITLE>checkdata</TITLE>
<script language="javascript">
<!--
// PURPOSE: Check to see if the string passed in is a valid time.
// A valid time is defined as a string which is postfixed with either
// "PM" or "AM". Next it checks to see if there is a colon in the
// string. If there is, it makes sure that at least one digit preceeds
// it and two proceed it.function chkdate(objName) {
var strDatestyle = "US"; //United States date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length==0) {
return false;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
if (strYear.length>4){
return false;
}
}
}
}// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}
if (isNaN(intMonth)) {
return false;
}
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
return false;
}
if (intMonth>12 || intMonth<1) {
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
return false;
}
if (intMonth == 2) {
if (intday < 1) {
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
return false;
}
}
else {
if (intday > 28) {
return false;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}function checkdata(){
var strdate=document.form1.strdate;
if (chkdate(strdate)==false){
alert("The date is Invalid!")
document.form1.strdate.select();
document.form1.strdate.focus();
return false;
}
}
//-->
</script>
</HEAD>
<BODY onload="javascript:test()">
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td width="45%">
<div align="right">Please input the Date:</div>
</td>
<td width="55%">
<input type="text" name="strdate">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center"> </div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="button" name="Button" value="Submit" onClick="javascript:checkdata()" style="cursor:hand">
</div>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<TITLE>checkdata</TITLE>
<script language="javascript">
<!--
// PURPOSE: Check to see if the string passed in is a valid time.
// A valid time is defined as a string which is postfixed with either
// "PM" or "AM". Next it checks to see if there is a colon in the
// string. If there is, it makes sure that at least one digit preceeds
// it and two proceed it.function chkdate(objName) {
var strDatestyle = "US"; //United States date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length==0) {
return false;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
if (strYear.length>4){
return false;
}
}
}
}// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}
if (isNaN(intMonth)) {
return false;
}
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
return false;
}
if (intMonth>12 || intMonth<1) {
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
return false;
}
if (intMonth == 2) {
if (intday < 1) {
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
return false;
}
}
else {
if (intday > 28) {
return false;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}function checkdata(){
var strdate=document.form1.strdate;
if (chkdate(strdate)==false){
alert("The date is Invalid!")
document.form1.strdate.select();
document.form1.strdate.focus();
return false;
}
}
//-->
</script>
</HEAD>
<BODY onload="javascript:test()">
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td width="45%">
<div align="right">Please input the Date:</div>
</td>
<td width="55%">
<input type="text" name="strdate">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center"> </div>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="button" name="Button" value="Submit" onClick="javascript:checkdata()" style="cursor:hand">
</div>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
var smail=/^[A-Za-z0-9_\-\.]+@[a-zA-Z0-9][a-zA-Z0-9_\.\-]+\.[a-zA-Z]{2,3}$/;
if (!smail.test(document.theform.mail.value)) {
alert("请务必填写正确的邮箱地址!");
document.theform.mail.focus();
document.theform.mail.select();
return false;
}
}