Saturday 27 September 2008

Date Validation in C#

public bool isDate(string strDate)
{
string strRegex = @"^\d{1,2}\/\d{1,2}\/\d{2,4}$";
Regex re = new Regex(strRegex);
if (re.IsMatch(strDate))
return (true);
else
return (false);
}


Name Space to be included::::

using System.Text.RegularExpressions;


How to use this function::::::
if (isDate(txtexpirydate.Text) == false)
{
Err_ind = 1;
lblerror.Text = "Check Expiry Date..!";
}