I have two TextBox controls for start date & end date input. I have to validate that end date is not greater than start date & the difference between start date & end date is not more than 12 months.
I have two TextBox controls for start date & end date input. I have
Share
You will have to use a
CustomValidatorto do this. In your markyou, you will have something like this:And in your code behind, you define the validation handler:
Note that the code above is prone to throw exceptions. You will need to add additional validators to check that the dates entered can be parsed, and the
ValidateDurationmethod should be modified to confirm that these other validators have passed before doing its own tests.Further, you might want to yet add another validator to test that the end date is in fact greater (or equal to) the start date. Breaking this rule should probably raise its own validation error message.