Please see my other MVC articles.
Using the Remote attribute to leverage JQuery’s validator.
MVC provides a flexible and powerful method for using logic external to the Model for enforcing business rules – the Remote attribute.
In this article, I will illustrate how to use an action method from a Controller to validate a Model’s attribute.
First, I’ll add the Remote attribute to the Model property on which I plan to execute external logic to validate the territory entered is one of the acceptable values – “OR.”
Next, I’ll implement the validation method called in the attribute – “ValidateTerritory()” located inside my Controller.
Now when I enter a value that isn’t one of the accepted territories, I get an error message.