<script language="javascript" src="Atlas.js"></script> //Atlas.js有下的 http://Atlas.asp.net //********************格式日期 var date = new Date() alert(date.toFormattedString("yyyy-MM-dd HH:mm:ss")); alert(date.toFormattedString("MM/dd/yyyy"));
Title: y/m/d Date Expression: ^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$
Description: This expression validates dates in the y/m/d format from 1600/1/1 - 9999/12/31. Follows the same validation rules for dates as my other date validator (m/d/y format) located in this library. Matches: 04/2/29|||2002-4-30|||02.10.31 Non-Matches: 2003/2/29|||02.4.31|||00/00/00
Title: Pattern Title Expression: (((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))
Description: Date in DD/MM/YYYY format. Fecha en formato DD/MM/AAAA. Matches: 28/12/2003|||28/02/2003|||29/02/2000 Non-Matches: 28-02-2003|||30/02/2003|||28.02.2003
{
var str=s;
alert(str);
//MMDDYY
var reg= /^(0[1-9]|1[0-2])[/](0[1-9]|[1-2]\d|3[0-1])[/][1-2]\d{3}$/;
var bool = reg.test(str);
alert(bool);
}</script><input type="text" value="12/23/1234" name="tt">
<input type="button" onclick="AlCheck(document.all.tt.value)" value="检测">
**
*函数功能:判断输入的字符串是否为合法的时间*
*输入参数:输入的字符串*
*返回值:true-合法的时间/false-非法的时间*
*调用函数:*
**
********************************************************************/
function checkDate(strDate)
{
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var strSeparator = "/";
var err = 0; strDateArray = strDate.split(strSeparator); if (strDateArray.length != 3)
{
err = 1;
return false;
}
else
{
strYear = strDateArray[2];
strMonth = strDateArray[0];
strDay = strDateArray[1];
} intday = parseInt(strDay, 10);
if (isNaN(intday))
{
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth))
{
err = 3;
return false;
}
intYear = parseInt(strYear, 10);
if(strYear.length != 4)
{
return false;
}
if (isNaN(intYear))
{
err = 4;
return false;
}
if (intMonth>12 || intMonth<1)
{
err = 5;
return false;
} if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
{
err = 6;
return false;
} if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
{
err = 7;
return false;
} if (intMonth == 2)
{
if (intday < 1)
{
err = 8;
return false;
} if (LeapYear(intYear) == true)
{
if (intday > 29)
{
err = 9;
return false;
}
}
else
{
if (intday > 28)
{
err = 10;
return false;
}
}
} return true;
}
//Atlas.js有下的 http://Atlas.asp.net
//********************格式日期
var date = new Date()
alert(date.toFormattedString("yyyy-MM-dd HH:mm:ss"));
alert(date.toFormattedString("MM/dd/yyyy"));
y/m/d Date
Expression:
^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$
Description:
This expression validates dates in the y/m/d format from 1600/1/1 - 9999/12/31. Follows the same validation rules for dates as my other date validator (m/d/y format) located in this library. Matches: 04/2/29|||2002-4-30|||02.10.31
Non-Matches: 2003/2/29|||02.4.31|||00/00/00
Pattern Title
Expression:
(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))
Description: Date in DD/MM/YYYY format. Fecha en formato DD/MM/AAAA. Matches: 28/12/2003|||28/02/2003|||29/02/2000
Non-Matches: 28-02-2003|||30/02/2003|||28.02.2003