Monday, October 28, 2013

Validating date using Range Validator asp net

Q: Why Validate date using Range Validator? 
A: All validation controls use culture specified in the web.config globalization tag. We don't need to hard code values every time we change culture. So using Range Validator as a date comparator makes things easy. To use range validator make sure to specify Type="Date" else it won't work. Choose Maximum and Minimum Values as required

<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Invalid Date" 
Type="Date" ControlToValidate="{}" MaximumValue="3000-12-12" MinimumValue="1900-12-12">
</asp:RangeValidator>

Thanks

No comments:

Post a Comment