1

I need to validate 2 dates: "begin date" and "end date". "Begin date" must from today to the future and "end date" must be equal or greater than "Begin date". How can I do it with Data Annotations? Is it possible?

4

1 Answer 1

3

You can do this with DataAnnotations as mentioned in bellow links:

  1. Greater Than or Equal To Today Date validation annotation in MVC3
  2. MVC Validation Lower/Higher than other value
  3. mvc4 data annotation compare two dates
  4. MVC custom validation: compare two dates

But, as an advice, solve this via Javascript libraries that are more easy than DataAnnotations like Jquery Input Mask

Sign up to request clarification or add additional context in comments.

1 Comment

Client-side Validation (like Jquery input Mask) is great, but always check server-side too .. ( stackoverflow.com/a/15855799/130420 )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.