MVC: Validation – Remote

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s