S
settyv
Hi,
I need to write a Javascript which calculates datedifference as well
as date comparision.When i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
var fromDate=new
Date(document.getElementById("txtFromFiledDate").value);
var toDate=new
Date(document.getElementById("txtToFiledDate").value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Difference is: " + diffDate);
alert(diffDate>30);
if(diffDate<0){alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
Thanks,
Vishnu
I need to write a Javascript which calculates datedifference as well
as date comparision.When i try to embed the below script,it is working
well,but the page is submitting even when the condition evaluates to
false .Please let me know the reason what is the problem in the below
script.
function ValidateDate()
{
var fromDate=new
Date(document.getElementById("txtFromFiledDate").value);
var toDate=new
Date(document.getElementById("txtToFiledDate").value);
var diffDate=new Date();
diffDate = (toDate - fromDate);
diffDate = ((((diffDate / 1000) / 60) / 60) / 24);
alert("Difference is: " + diffDate);
alert(diffDate>30);
if(diffDate<0){alert("Start Date cannot be after End Date!")
return false;}
if(diffDate>30 && diffDate<0) {alert("Please enter the date in
Range")
return false;}
return true;
}
Thanks,
Vishnu