Remote validation in asp.net mvc with example

For Consultation : +91 9887575540

Stay Connected :

Remote attribute in asp.net MVC

What is Remote Attribute

  • make a remote server call to validate specific data without posting the entire form to the server
  • Remote is an attribute of data annotation
  • Used for validation at model class in MVC.
  • Implemented with the use of jquery, jquery.validate.min.js, jquery.validate.unobtrusive.

Note: Do not forget to add the following code at the view


Example 1: Single model attribute validation

Step1: Create a database table (here table name is login in angular database)

Remote validation example in mvc

Step2: Create a Model and dbContext class using code first (if you are not aware with it, Please watch the video which is given below)

[Remote(“CheckUserName”,”RemoteValidationEx”, ErrorMessage =”Username already exists”)] 

CheckUserName: It is JSON Action which will be defined in the controller to validate username is already exists or not, will return true or false.

RemoteValidationEx:Controller name where CheckUserName exists.

ErrorMessage: Which has to show as a validation error.

Step 3: Create a Controller class (RemoteValidationEx) and add the following code.


Step 3: Run your code and see the following URL.


(Note: localhost:50720 it will be changed as per your application port)

RemoteValidation With Example in MVC

ASP.NET MVC Remote Validation For Multiple Fields With AdditionalFields Property

Step : 1 Change in Model Property of previous code (login.cs)

Step 2: Change in controller


Select your currency
Open chat
Powered by