ate[2]);
if(date.getYear() == arrDate[0]
&& date.getMonth() == (parseInt(arrDate[1],10) -1)+""
&& date.getDate() == arrDate[2])
return true;
else
return false;
}
function checkDateEarlier(strStart,strEnd)
{
if(checkIsValidDate(strStart) == false || checkIsValidDate(strEnd) == false)
return false;
if (( strStart == "" ) || ( strEnd == "" ))
return true;
var arr1 = strStart.split("-");
var arr2 = strEnd.split("-");
var date1 = new Date(arr1[0],parseInt(arr1[1].replace(/^0/,""),10) - 1,arr1[2]);
var date2 = new Date(arr2[0],parseInt(arr2[1].replace(/^0/,""),10) - 1,arr2[2]);
if(arr1[1].length == 1)
arr1[1] = "0" + arr1[1];
if(arr1[2].length == 1)
arr1[2] = "0" + arr1[2];
if(arr2[1].length == 1)
arr2[1] = "0" + arr2[1];
if(arr2[2].length == 1)
arr2[2]="0" + arr2[2];
var d1 = arr1[0] + arr1[1] + arr1[2];
var d2 = arr2[0] + arr2[1] + arr2[2];
if(parseInt(d1,10) > parseInt(d2,10))
return false;
else
return true;
}
String.prototype.len = function(){
return this.replace(/[^\x00-\xff]/g,"aa").length;
}
function check()
{
var Start = document.form1.start_y.value + "-" + document.form1.start_m.value + "-" + document.form1.start_d.value;
var End = document.form1.end_y.value + "-" + document.form1.end_m.value + "-" + document.form1.end_d.value;
if(document.form1.title.value == '')
{
alert('请填写调查名称');
document.form1.title.focus();
return false;
}
if(document.form1.title.value.len() > 100)
{
alert('调查标题不能超过100个字')
document.form1.title.focus();
return false;
}
if(!checkDateEarlier(Start,End))
{
alert('开始日期不能小于结束日期');
return false;
}
}
</script>
</body>
</html>