home / software / tips and tricks / How to add Remote validation to MVC 3.0?

How to add Remote validation to MVC 3.0?

Updated:  09/18/2013 11:09 AM
Author:  Shiju Mathews

Status:    Resolved.


Step 1
Complete the server side custom ValidationAttribute, Refer How to create a custom ValidationAttribute in MVC 3?

Step 2
Open files TimeCard.cs in Model folder.
Add a reference to “System.Web.Mvc” namespace.
Add Remote Validation Attribute to Username Property.

Where TimeSheet is the Controller and CheckUsername is the JsonResult(similer to ActionResult)

Step 3
Open TimeSheetController and add the method CheckUsername


Step 4
Run the project in Visual studio and navigate to the view where the model is using. In this example any username other that Shiju will give error “Invalid Username”.
Tags: How to add Remote validation to MVC 3.0?
Updated on: November 2024