1

I want to restrict user from entering a date except a particular range in my MVC 4 application. Please suggest how can I do this.

7
  • what have you tried so far? what validation framework are you using? are you validating on the client, server or both? Commented May 3, 2013 at 12:09
  • You have to implement self validated class. Use IValidatableObject and take a look here weblogs.asp.net/scottgu/archive/2010/07/27/… Commented May 3, 2013 at 12:10
  • This link will be helpful for date range validation stackoverflow.com/questions/13183647/… Commented May 3, 2013 at 12:15
  • @JasonMeckley: I have to implement on both server as well as client. I have implemented server side validation by inheriting my class 'DateRangeAttribute' with 'ValidationAttribute' class and it is working fine. But I need it on client side also. So is there a inbuilt or predefined approach to do this? Commented May 3, 2013 at 12:15
  • 1
    You should state in your question that you have implemented server-side validation, and that you need to implement client-side validation. Otherwise, people will see the C# tag and automatically think server-side. Commented May 3, 2013 at 12:30

1 Answer 1

0

You can implement IValidatableObject interface and using Validate method to do this validation.

check Using IValidatableObject Custom Validation

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

Comments

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.