Here is my javscript:
- Code: Select all
function submit_advSearch(){
debugger;
var startDate = advSearch.startdate.value;
var endDate = advSearch.enddate.value;
var call_datetime = '';
var sdate;
var edate;
//validate startdate < enddate
if(startDate != ''){
sdate = new Date(startDate.replace("-","/"));
}
if(endDate !=''){
edate = new Date(endDate.replace("-","/"));
}
if (startDate !='' && endDate != '' && sdate > edate){
alert('Start Date must be earlier than End Date');
return false;
}
//END: validate startdate < enddate
//Build call_datetime
if (startDate != ''){
call_datetime = '>=' + startDate + '%2000:00:00';
}
if (startDate != '' && endDate != ''){
call_datetime += '+AND+<=' + endDate + '%2023:59:59';
}else if(startDate != '' && endDate == ''){
call_datetime = '>=' + startDate;
}else if(startDate == '' && endDate != ''){
call_datetime = '<=' + endDate + '%2023:59:59';
}
document.advSearch.call_datetime.value = call_datetime;
document.advSearch.submit();
}