Re: Please help me how to call this Javascript
- From: Milosz Skalecki <mily242@xxxxxxxxxxxxx>
- Date: Thu, 26 Oct 2006 17:06:02 -0700
Show us more code (espacially text boxes declaration)
--
Milosz Skalecki
MCP, MCAD
"settyv@xxxxxxxxx" wrote:
Hi,.
It is not working .it is telling script error.Here is the HTML created
after the postback.Everything is fine.But i dont know why it is telling
error.
Microsoft JScript runtime error: 'document.GetElementById.txtFromDate'
is null or not an object
<TR vAlign="top">
<TD colSpan="4" height="25"></TD>
<TD><input type="submit" name="btnSubmit" value="Submit"
id="btnSubmit" onClick="return
ValidateDate(document.getElementById["txtFromDate"].Value,document.getElementById["txtToDate"].Value);"
/></TD>
</TR>
Please let me know how can i solve this.
Thanks,
Vishnu
rampabbaraju@xxxxxxxxx wrote:
Try this
btnSubmit.Attributes.Add("onClick"," return
ValidateDate(document.GetElementById('" +
txtFromDate.ClentId() + ').Value",document.GetElementById('" +
txtToDate.ClentId()+ "'));");
settyv@xxxxxxxxx wrote:
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
- Follow-Ups:
- Re: Please help me how to call this Javascript
- From: settyv
- Re: Please help me how to call this Javascript
- References:
- Please help me how to call this Javascript
- From: settyv
- Re: Please help me how to call this Javascript
- From: rampabbaraju
- Re: Please help me how to call this Javascript
- From: settyv
- Please help me how to call this Javascript
- Prev by Date: RE: Question about DataList
- Next by Date: Re: populate array with sql table data vb.net
- Previous by thread: Re: Please help me how to call this Javascript
- Next by thread: Re: Please help me how to call this Javascript
- Index(es):
Relevant Pages
|