//函数名:CheckDateTime
//功能介绍:检查是否为日期时间
function CheckDateTime(str){
var reg = /^(\d+)-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
var r = str.match(reg);
if(r==null)return false;
r[2]=r[2]-1;
var d= new Date(r[1], r[2],r[3], r[4],r[5], r[6]);
if(d.getFullYear()!=r[1])return false;
if(d.getMonth()!=r[2])return false;
if(d.getDate()!=r[3])return false;
if(d.getHours()!=r[4])return false;
if(d.getMinutes()!=r[5])return false;
if(d.getSeconds()!=r[6])return false;
return true;
}
/**
判断输入框中输入的日期格式为yyyy-mm-dd和正确的日期
*/
function IsDate(sm,mystring) {
var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
var str = mystring;
var arr = reg.exec(str);
if (str=="") return true;
if (!reg.test(str)&&RegExp.$2<=12&&RegExp.$3<=31){
alert("请保证"+sm+"中输入的日期格式为yyyy-mm-dd或正确的日期!");
return false;
}
return true;
}
function toDateFromString( strDate )
{
if (strDate.length != 8) {
return null ;
}
var dtDate = null ;
var nYear = parseInt( strDate.substring( 0, 4 ), 10 ) ;
var nMonth = parseInt( strDate.substring( 4, 6 ), 10 ) ;
var nDay = parseInt( strDate.substring( 6, 8 ), 10 ) ;
if( isNaN( nYear ) == true || isNaN( nMonth ) == true || isNaN( nDay ) == true )
{
return null ;
}
dtDate = new Date( nYear, nMonth - 1, nDay ) ;
if( nYear != dtDate.getFullYear() || ( nMonth - 1 ) != dtDate.getMonth() || nDay != dtDate.getDate() )
{
return null ;
}
return dtDate ;
}
YYYYMMDD的格式
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有