0

I am new to MVC4. I have a MyModel class with "public string myValue" member. I need to validate it's value, on the Client Side (after user enters it in View) against maximum value (maxVal) that is retrieved from database and belongs to the different model (DiffModel). I have tried [Range(..] validation attribute, but it requires const parameters. I am looking now into creating custom validation attribute (cva), but it looks like cva will run on Server side, and Not on client side. Please suggest how to resolve with this situation if it's possible at all. Thank you

1 Answer 1

0

Example of how you do it:

public class ViewModel
{
    public DateTime MinDate {get; set;}
    public DateTime MaxDate {get; set;}

    [DynamicRange("MinDate", "MaxDate", ErrorMessage = "Value must be between {0} and {1}")]
    public DateTime Date{ get; set; }
}

Changing validation range programmatically (MVC3 ASP.NET)

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.