Forums - C# Corner

Forum guidelines
richard smith

richard smith

  • 613
  • 140
  • 78.9k

Validate Date

Feb 4 2013 11:27 AM
I have a text box on a web form where a user will input a Discharge Date...The date MUST be entered in this format MM/DD/YYYY what C# code would validate that the entry is input in that format, and if not show an error?  Something like:
ButtonFinish_Click()
{
//check to see if the date is correct format
try
{
//how to check?
//if valid Response.Redirect -- Go to next page
}
catch
{
Error.Text = "Dates must be entered in a MM/DD/YYYY Format.  Please check the entry and try again."

Answers (7)

C# Corner Hyderabad Developer Conference

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.