Code Snippet posted by:
Shubham | Posted on: 8/1/2012 | Category:
C# Codes | Views: 692 | Status:
[Member] |
Points: 40
|
Alert Moderator
set a textbox(txtDob)on page and set the calender on textbox click event and select the date from calender...
protected void btn_Click(object sender, EventArgs e)
{
DateTime dtStart = DateTime.Parse(txtDoB.Text);
TimeSpan sp = DateTime.Now - dtStart;
int year =18\\\\\\ pass the no of year of no you want to validate
int days = 365;
int total = year * days;
if (sp.Days < total)
{
txtDoB.Text = "Not Valid";
lblMess.Text = "You can not be under 18 years";
lblMess.CssClass = "Errr";
return;
}
Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar
Found interesting? Add this to: