//验证给定的日期是否合法
function IsDate(str)
{
var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
if(r="=null)return" false; var d = new Date(r[1], r[3]-1, r[4]);
return (d.getFullYear()="=r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}
//验证给定的时间是否合法
function IsTime(str)
{
var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);
if(r="=null)return" false; var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
return (d.getFullYear()="=r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}
//常用的邮箱合法性验证
function isEmail(email)
{
invalidChars = " /;,:{}[]|*%$#!()`<>?";
if (email ="=" "")
{
return false;
}
for (i="0;" i< invalidChars.length; i++)
{
badChar = invalidChars.charAt(i)
if (email.indexOf(badChar,0) > -1) {
return false;
}
}
atPos = email.indexOf("@",1)
if (atPos ="=" -1) { return false; }
if (email.indexOf("@", atPos+1) != -1) { return false; }
periodPos = email.indexOf(".",atPos)
if(periodPos ="=" -1) {
return false; // and at least one "." after the "@"
}
if ( atPos +2 > periodPos) {
return false; // and at least one character between "@" and "."
}
if ( periodPos +3 > email.length) { return false; }
return true;
}
//特殊后缀名的邮箱验证方法
//这个验证主要就是把邮箱的一些后缀名给列举出来了!这样就防止了一些后缀名的问题的验证了!
function isMail(s)
{
var patrn="/^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/; "
if (!patrn.exec(s)) {return false;}
return true;
}