>< script language=vbScript > >sub txtTodaysDate_OnBlur() > if len(trim(frmCustomer.txtTodaysDate.Value))> 0 then > if Not IsDate(frmCustomer.txtTodaysDate.Value) then > alert ("Not a valid date") frmCustomer.txtTodaysDate.focus() > end if > end if >end sub >< /script > >>
>>private void Validate_date( object sender, ServerValidateEventArgs e) >>{ >> lblMessage.Text = ""; >> e.IsValid = true; >> >> if ( !IsDate( e.Value) ) >> { >> e.IsValid = false; >> >> cv_IssuedDate.ErrorMessage = "Invalid Date!"; >> lblMessage.Text = "Issued Date Invalid"; >> } >> } >> >> public bool IsDate(string sdate) >> { >> DateTime dt; >> bool isDate = true; >> try >> { >> dt = DateTime.Parse(sdate); >> } >> catch (Exception e) >> { >> isDate = false; >> lblMessage.Text = e.Message; >> } >> return isDate; >> } >>>>The problem is that is always returning Invalid date even when I type a correct date