Date validation C# asp.net.

I need to be able to validate that a year put in to a text box is greater than the year 1900.  I have no idea of how to accomplish this.  Please help.
Pemberley1Asked:
Who is Participating?
 
jj819430Connect With a Mentor Commented:
TextBox T is the TextBox you have on the page.

DateTime EnteredDate = Convert.ToDateTime(T.Text);  // put in a try catch to make sure that it works.
if(EnteredDate.Year < 1900)
{
uh oh
}
else
{
ok
}
0
 
jj819430Commented:
<= instead of < if it cannot be 1900

you can also do it as
System.DateTime Acceptable = Convert.ToDateTime("1/1/1900");
if(Convert.ToDateTime(T.Text) > Acceptable)
{
ok
}
else
{
uh oh
}
0
 
Pemberley1Author Commented:
Thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.