pravin gurav

pravin gurav

  • NA
  • 1
  • 2.1k

C# date validation

May 23 2012 7:56 AM
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; }

Answers (1)