S
settyv
Hi,
Below is the Javascript function that am trying to call from asp:Button
control.
<script language="javascript">
function ValidateDate(fromDate,toDate)
{
var fromDate=new Date();
var toDate=new Date();
var diffDate = Math.round( ( toDate-fromDate ) / 864e5 );
alert(diffDate);
if( diffDate < 0 )
{
alert( "The start date cannot be after the end date!")
return false;
}
if( diffDate > 30 )
{
alert( "Please enter dates less than 31 days apart" )
return false;
}
return true; //allow submit
}
</script>
In code-behind am calling the function like as below:
btnSubmit.Attributes.Add("onClick"," return ValidateDate(" +
txtFromDate.Text.ToString() + "," + txtToDate.Text.ToString() + ");");
But if start entering the dates,it submits the page as it takes both
datee as current dates.Please let me know the reason.
Thanks,
Vishnu
Below is the Javascript function that am trying to call from asp:Button
control.
<script language="javascript">
function ValidateDate(fromDate,toDate)
{
var fromDate=new Date();
var toDate=new Date();
var diffDate = Math.round( ( toDate-fromDate ) / 864e5 );
alert(diffDate);
if( diffDate < 0 )
{
alert( "The start date cannot be after the end date!")
return false;
}
if( diffDate > 30 )
{
alert( "Please enter dates less than 31 days apart" )
return false;
}
return true; //allow submit
}
</script>
In code-behind am calling the function like as below:
btnSubmit.Attributes.Add("onClick"," return ValidateDate(" +
txtFromDate.Text.ToString() + "," + txtToDate.Text.ToString() + ");");
But if start entering the dates,it submits the page as it takes both
datee as current dates.Please let me know the reason.
Thanks,
Vishnu