<script>
String.prototype.isDate = function()
{
var r = this.match(/^(\d{4})(\d{2})$/);
if(r==null)return false; var d = new Date(r[1], r[2]-1,'1');
if((d.getFullYear()==r[1]&&(d.getMonth()+1)==r[2]&&d.getDate()=='1')){ if(this>=199201 && this<=200708){
return true;
}else{
return false
}
}else{
return false
}
}
alert("200709".isDate());
alert("200216".isDate());
alert("200211".isDate());
</script>6位的,
String.prototype.isDate = function()
{
var r = this.match(/^(\d{4})(\d{2})$/);
if(r==null)return false; var d = new Date(r[1], r[2]-1,'1');
if((d.getFullYear()==r[1]&&(d.getMonth()+1)==r[2]&&d.getDate()=='1')){ if(this>=199201 && this<=200708){
return true;
}else{
return false
}
}else{
return false
}
}
alert("200709".isDate());
alert("200216".isDate());
alert("200211".isDate());
</script>6位的,
String.prototype.isDate = function()
{
var r = this.match(/^(\d{4})(\d{2})$/);
if(r!=null){
var d = new Date(r[1], r[2]-1,'1');
if((d.getFullYear()==r[1]&&(d.getMonth()+1)==r[2]&&d.getDate()=='1')){ if(this>=199201 && this<=200708){
return true;
}else{
return false
}
}else{
return false
}
}
var mm = this.match(/^(\d{4})(\d{2})(\d{2})$/);
if(mm!=null){
var d = new Date(mm[1], mm[2]-1,mm[3]);
if((d.getFullYear()==mm[1]&&(d.getMonth()+1)==mm[2]&&d.getDate()==mm[3])){ if(this>=19920101 && this<=20070828){
return true;
}else{
return false
}
}else{
return false
}
}
var mmm = this.match(/^(\d{4})$/);
if(mmm!=null) {
if(this>=1992 && this<=2007){
return true;
}else{
return false
}
}
if(r==null && mm==null && mmm==null){
return false
}}
alert("200709".isDate());
alert("200216".isDate());
alert("200211".isDate());
alert("20021103".isDate());
alert("20070828".isDate());
alert("20070829".isDate());
alert("2009".isDate());
</script>全的