1
Answer

C# date validation

pravin gurav

pravin gurav

12y
1.8k
1
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)