RangeValidator is a validation control provided by asp.net. This control can be used to validate a range of string, date, integer and double values. In this post, I will show how to use the RangeValidator to validate a range of date using today’s date as the maximum value.
The following is the RangeValidator markup.
The TextBox control is added where the users will enter the value. The Button control is added to test validation. The RangeValidator is added – its ControlToValidate property is set to TextBox’s id, data type is set to Date, the minimum value is set to an arbitrary date. The maximum value is set in the Page_Load event as shown below.
The maximum value expects a value of type string, so the string format of today’s date is passed as the MaximumValue.