Skip to content

C# date validation

pravin gurav

Asked May 23, 2012, 3:56 AM EDT1 answer
Share
LinkedInX
TypeScript
private Boolean validateDate(string businessDate)
{
  Boolean dateValidationResult = true;
  try
  {
    IFormatProvider culture = new CultureInfo("fr-FR",true);
    DateTime.ParseExact(businessDate, "dd/MM/yyyy", culture);
  }
  catch (Exception exceptionObject)
  {
    dateValidationResult = false;
  }
  return dateValidationResult;
}



if (this.validateDate(businessDateTextBox.Text)== false)
{
  MessageBox.Show("Please write Accurate Business Date");
  businessDateTextBox.Focus();
  validationResult = false;        
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    What is the Error Or Problem with out sufficient information We are not able to help you.
    0