Common.js:
//时间格式化
function getDateByFormat(oldDate){
var Dy = oldDate.getFullYear();
var Dm = oldDate.getMonth()+1;
var Dd = oldDate.getDate();
if(Dm<10){
Dm = "0" + Dm;
}
if(Dd<10){
Dd = "0" + Dd;
}
var newDate = Dy+'-'+Dm+'-'+Dd;
return newDate;
}
//日期-时间格式化
function getDateTimeByFormat(oldDate){
var Dy = oldDate.getFullYear();
var Dm = oldDate.getMonth()+1;
var Dd = oldDate.getDate();
var Dh = oldDate.getHours();
var Dmi = oldDate.getMinutes();
var Ds = oldDate.getSeconds();
if(Dm<10)
Dm = "0" + Dm;
if(Dd<10)
Dd = "0" + Dd;
if(Dh<10)
Dh = "0" + Dh;
if(Dmi<10)
Dmi = "0" + Dmi;
if(Ds<10)
Ds = "0" + Ds;
var newDate = Dy+'-'+Dm+'-'+Dd+' '+Dh+':'+Dmi+':'+Ds;
return newDate;
}
//只能输入数字
function txtnumber()
{
if ((event.keyCode >57) || (event.keyCode <48))
return false;else return true;
}
//只能输入数字和字母
function txtnumchar()
{ //65- 90 97-122
var kcode = event.keyCode;
if (kcode >= 48 && kcode <= 57)
return true;
else if(kcode >= 65 && kcode <= 90)
return true;
else if (kcode >= 97 && kcode <= 122)
return true;
else
return false;
}
getCommonTable.js
复制代码 代码如下: