Take the 2-minute tour ×

I have select criterion for the to and from dates in asp.net as below.I want to include validation for date format and also for the comaprision. How can i include below requirements in asp.net validations on sub,it button click?

  1. If user select either TO or FROM date he must select both means TO and FROM also.
  2. If the TO date is less than FROM date error message should be displayed.

enter image description here

share|improve this question
@Avd to my knowledge compareValidator is for exact comparision and RequiredField i dont how i can leverage. @V4Vendetta working on it. –  Pratik Jul 13 '12 at 7:54

1 Answer 1

up vote 0 down vote accepted

To check the format, use CompareValidator

<asp:CompareValidator Operator="DataTypeCheck" Type="Date" ...

To check the end date is after the start, try another CompareValidator (this should work - not tested)

<asp:CompareValidator Operator="GreaterThan" 

To check your more complex requirements, use the CustomValidator

share|improve this answer

Your Answer


