i have create a function to calculate date. whenever i enter it to the system, there having extra date. why get like that. the coding is just like the below.
function calculateDate(value)
{
if (document.form.fromDate.value != null && value != null)
{
var date = getDate(document.form.fromDate.value);
date.setDate(date.getDate() + parseInt(value)-1);
var curr_date = date.getDate();
var curr_month = date.getMonth()+ 1;
var curr_year = date.getFullYear();
var dateString = formatString(curr_date) + "-" + formatString(curr_month) + "-" + curr_year;
document.form.toDate.value= dateString;
}
}
function calculateValidDays()
{
if (document.form.fromDate.value != null && document.form.toDate.value != null)
{
var fromDate = getDate(document.form.fromDate.value);
var toDate = getDate(document.form.toDate.value);
var date = new Date();
date.setTime(Math.abs(fromDate.getTime() - toDate.getTime()));
days = Math.floor(date.getTime() / (1000 * 60 * 60 * 24));
document.form.days.value= days+1;
}
else if(document.form.toDate.value != null && document.form.days.value != "")
{
var date = getDate(document.form.toDate.value);
date.setDate(date.getDate() - parseInt(document.form.days.value));
var curr_date = date.getDate();
var curr_month = date.getMonth()+ 1;
var curr_year = date.getFullYear();
var dateString = formatString(curr_date) + "-" + formatString(curr_month) + "-" + curr_year;
document.form.fromDate.value= dateString;
}
else if(document.form.fromDate.value != null && document.form.days.value != "")
{
var date = getDate(document.form.fromDate.value);
date.setDate(date.getDate() + parseInt(document.form.days.value)+1);
var curr_date = date.getDate();
var curr_month = date.getMonth()+ 1;
var curr_year = date.getFullYear();
var dateString = formatString(curr_date) + "-" + formatString(curr_month) + "-" + curr_year;
document.form.toDate.value= dateString;
}
}