Posts

Showing posts with the label Remote Validation

Donate

Restrict Remote Validation In ASP.NET MVC Edit Mode.

Hello, In data entry operations, we normally validate user input if they exist in the database, if yes we throw some kind of exception or error message that the data they entered already exists in the database. But in scenario like editing of existing information, we don't want this to happen. So to restrict the remote validation in ASP.NET MVC, I found the fix from stack Remote validation restrict for edit controller method but modified the logic in the controller which is to return a JSON rather than a bool value. The code modifications are as follows. Edit View or Edit Partial View: Add another HiddenField for Initial Product Code used for Comparison. @Html.Hidden("InitProductCode", Model.ProductCode) Model: Add AdditionalFields in Remote Attribute. [Display(Name = "Product Code")] [Required(ErrorMessage = "ProductCode is required")] [Remote("CheckProductCode", "Products", HttpMethod = "POST", ErrorMessage = &q

ASP.NET MVC 5 Client-Side Remote Validation Using jQuery

Image
When integrating jQuery validation in ASP.NET MVC, here's how to apply client-side remote validation using javascript code. Below are the snippets and screenshots. Make sure to render the jquery.validate.min.js file in your View or Layout. Email HTML Markup: 1 2 3 4 5 6 7 <div class= "form-group has-feedback" > <label for= "email" class= "control-label col-md-3" >Email Address:</label> <div class= "col-md-9" > <input type= "email" name= "email" id= "email" class= "form-control" placeholder= "Enter email" /> <span class= "glyphicon form-control-feedback" id= "email1" ></span> </div> </div> Custom Javascript Validation Code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $( function () { $( "#frmInput" ).validate({ sub

Donate