Click here to Skip to main content
15,916,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can we validate Textbox Date of Birth . in asp.net which take input more than 18 years.
Posted

Hi ,
You can use RangeValidator

ASP.NET
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
      <asp:RangeValidator ID="RangeValidator1" runat="server"
          ControlToValidate="TextBox1" Display="Dynamic" ErrorMessage="less than 18 "
          MaximumValue="1/1/2080" MinimumValue="01/01/1994" SetFocusOnError="True"
          Type="Date"></asp:RangeValidator>

Best Regards
M.Mitwalli
 
Share this answer
 
Comments
bbirajdar 2-Apr-12 6:00am    
Correct answer.. My 5
Mohamed Mitwalli 2-Apr-12 6:07am    
Thx :)
You might need to use regular expression to validate this....
 
Share this answer
 
You can use Custom Validator[^] and check the difference between date of birth and today's date should be greater than 18 years.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900