Http://social.msdn.microsoft.com/forums/en-US/showandtell/thread/e2a94c9b-96a4-4d8f-ae85-cf242cd45afa/
This a UK style of date validation. This can be changed to cater us style as well. Add this script in the head tag of HTML page
<SCRIPT type = text/JavaScript>
// This function is used to validate date in the format DD/MM/YYYY (U. K. Style)
// Dtcontrol is the Client ID of the control which contains the date
Function validatedate (dtcontrol)
{
VaR input = Document. getelementbyid (dtcontrol)
VaR validformat =/^ \ D {1, 2} \/\ D {1, 2} \/\ D {4} $ // basic check for format Validity
VaR returnval = false
If (! Validformat. Test (input. Value ))
Alert ('invalid date format. please correct .')
Else {// detailed check for valid date ranges
VaR dayfield = input. value. Split ("/") [0]
VaR monthfield = input. value. Split ("/") [1]
VaR yearfield = input. value. Split ("/") [2]
VaR dayobj = new date (yearfield, monthfield-1, dayfield)
If (dayobj. getmonth () + 1! = Monthfield) | (dayobj. getdate ()! = Dayfield) | (dayobj. getfullyear ()! = Yearfield ))
Alert ('invalid day, month, or year range detected. please correct .')
Else
{
Returnval = true
}
}
If (returnval = false) Input. Focus ()
Return returnval
}
</SCRIPT>
This can be set to work on client side now. For example, use this function on blur of a text box:
<Asp: textbox id = "m_txtdate" runat = "server" onblur = "validatedate ('m _ txtdate ')"> </ASP: textbox>
Add this code in your ASPX page. hope this works! Cheers