用JavaScript来格式化日期,要求日期格式为 YYYY/MM ,当输入如:2008/1 时,自动格式化日期为2008/01
function FormatDate(objValue)
{
objValue = objValue.toString();
if(objValue.trim().length<=0){
return "";
}
var dateYM = objValue.trim();
if(dateYM.length == 6 && dateYM.indexOf("/") == 4) {
dateYM = dateYM.replace("/","/0");
return dateYM;
}
else {
return dateYM;
}
}
function FormatDate(objValue)
{
objValue = objValue.toString();
if(objValue.trim().length<=0){
return "";
}
var dateYM = objValue.trim();
if(dateYM.length == 6 && dateYM.indexOf("/") == 4) {
dateYM = dateYM.replace("/","/0");
return dateYM;
}
else {
return dateYM;
}
}