I have a Text Box on my ASP.Net page with a mask of 99/99/9999, and it should only accept a Date. I want to be able to type in only a 0 as a shortcut and have some Javascript change the value to the current date. I'm using the OnBlur event on my page to call the Javascript function:
<asp:TextBox runat="server" onblur="SetToCurrentDate(this);" />
My Javascript function looks something like this:
function SetToCurrentDate(myDate)
{
if (myDate.value == "0_/__/____")
{
myDate.value = "15/04/2010";
}
}
I know that I'm getting into the if condition as I've tried using an alert to display a message. However, my Text Box is not getting its value changed to 15/04/2010.
I'm sure I've got something pretty straightforward wrong here, but as a newcomer to ASP.Net and Javascript, I'm really scratching my head with this.
I'd really appreciate any advice.
Thanks.
<asp:TextBox runat="server" onblur="SetToCurrentDate(this);" />
My Javascript function looks something like this:
function SetToCurrentDate(myDate)
{
if (myDate.value == "0_/__/____")
{
myDate.value = "15/04/2010";
}
}
I know that I'm getting into the if condition as I've tried using an alert to display a message. However, my Text Box is not getting its value changed to 15/04/2010.
I'm sure I've got something pretty straightforward wrong here, but as a newcomer to ASP.Net and Javascript, I'm really scratching my head with this.
I'd really appreciate any advice.
Thanks.