.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

ASP.NET MVC with JQuery Validation and ValidationSummary

Posted By: imran_ku07     Posted Date: August 24, 2010    Points: 0   Category :ASP.Net


          One of the great feature of ASP.NET MVC 2 is the support of client side validation. Client side validation

View Complete Post

More Related Resource Links

JQuery vs MS client validation


I have been trying both MicrosoftMvcJQueryValidation.js and MicrosoftMvcValidation.js.

The former does not support validation summarie, while the latter does.

Neither one of them seems to be able to deal with System.ComponentModel.DataAnnotations.DataType markings on the client side. It somewhat defeats the purpose of having the attributes on the server side. I know the validation on the server side works, but I need it to work on the client too.

Is there an easy way to make the client side validation for that work?

Are there any updates to these javascript libraries that I am may not be aware of?

Client Side Validation with jQuery


I have used client side validation with Ajax before.  Now I need to do client side validation with jQuery.

I am referencing jQuery 1.4.2 and jQuery.validation version 1.7.

I have added <% Html.EnableClientValidation(); %> to the view.

I have added Html.TextBoxFor and Html.ValidationMessageFor to the view.

Client side validation still does not work.

If I understand correctly, I also need to include MicrosoftMvcJQueryValidation.js.  This file was not installed with VS 2010 ultimate.  I have heard that it is available on the Futures project, but the links to the site are broken.

Do I need MicrosoftMvcJQueryValidation.js to make client side validation work?

If so, where do I find the current version of MicrosoftMvcJQueryValidation?  Why isn't it readily available for download or included with VS 2010?

If not, what do I do next to get client side validation to work?

I know that I could manually add calls to jQuery validation, but that is far from ideal - especially since the Ajax v

MVC2 client validation with jquery dialog


i am trying to get mvc2 client validation working with a jquery dialog, i have pretty much been using the mvc music store example at http://www.asp.net/mvc. if i go to http://localhost/Build/Edit/11, client validation works, but it will not work in the jquery dialog. any ideas?

ViewActive.aspx - main page with a link to popup a form


function showModalEdit(id) {

            var $loading = $('<img src="<%= Url.Content("~/Content/Images/ui-anim_basic_16x16.gif") %>" alt="loading"/>');

            var $dialogEdit = $('<div id="dialogEdit"></div>').append($loading.clone());



                height: 768,

                width: 1024,

                autoOpen: false,

                title: "Modify Build",


jquery validation error message - place in the specified div whose class is putmehere !



I decided to use jquery validations because asp.net validation controls are so crazy inside the update panel.

But I need to plase the error messages in the specified div whose class is putmehere ! I am unable to do that. here is my code;

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <script src="../JQuery/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="../JQuery/Validation/jquery.validate.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
                rules: {
                    <%=TextBox1.UniqueID %>: {
                        minlength: 2,
                        required: true
                     <%=TextBox2.UniqueID %>: {                       
                        required: true,
                }, messages: {
                    <%=TextBox1.UniqueID %>:{
                        required: "* Required Field *",
                        minlength: "* Please enter atleast 2 characters *"

beginner validation: jquery vs javascript vs codebehind




I've a webform that has around 10 textboxes that are filled with information from an event trigered by combobox.  so far so good.  The thing is that I need  that some textboxes should be validated against the sum of values of others,  and according to that assign given values.  Other textboxes should have a value according to those sum and datefield values.  I haven't found validation controls for asp.net so I assume that I should to it with javascript or jquery.  My concern as asp.net beginner is what happens if the user disables javascript?  If I make it with codebehind I'll have to refresh the page many times as I have many controls to validate.  What can I do ?


thanks in advance.



Problem with Jquery windows modal + Validation Summary


Hi all, 

I have a jquery windows modal with some textboxes and a OK button, i have placed some field validators to 
respective textboxes with ValidationGroup. 

When the windows modal opens, the required field validator are  working when clicking on 

OK button but i cannot to visualize the error summary. 

how can i do to visualize the summary? 

thx in advance!

checkbox and dropdown validation using jquery+asp.net


i have a checkbox and dropdown in a gridview when user selects checkbox only then he can select the dropdown, and the dropdown wil have the values corresponding to the gridview rows count

if user checks two checkbox in a gridview,and  the dropdown value should be diffrent it should be not the same for the selected checkbox

how to achieve this using Jquery and asp.net


jQuery Custom Invalid Validation



Is there a method in jQuery that I can customize an invalid validation myself instead of using jQuery plug-in validation?

For example, if the form is valid do this below.

if ($('form').valid()) {
    //do something

But if I wanted to have a cutomize invalid method I could do this below.


if (!x == y) {
     $('form').valid() = False; //Sad   

     alert('Form is not valid.');

Thank You,


jQuery Validation of Username in MVC



The below code is not working when validating a unique username but the required rule works.

<script src="http://ajax.microsoft.com/ajax/jQuery.Validate/1.6/jQuery.Validate.min.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(document).ready(function () {

                    username: {
                        required: true,
                        uniqueUsername: (function () {

jquery validation in ascx page


Following on from my post about using ascx pages for the content of the jquery tab panels.


Can I use jquery validation on each ascx page before submitting to move to the next tab panel?

I've been trying the following way, but when I click the submit button I get the error 'Object doesn't support this property or method'.


<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
    <div id="tabs">
            <li><a href="#tab1">Your Details</a></li>
            <li><a href="#tab2">Course Details</a></li>
            <li><a href="#tab3">Education & Employment</a></li>
            <li><a href="#tab4">References</a></li>
            <li><a href="#tab5">Submit Application</a></li>
        <div id="tab1">
            <asp:PlaceHolder ID="plhApp" runat="server"></asp:PlaceHolder>

jQuery validation




I have a form om my sharepoint site and I want to add some validation (required fields) with jQuery.


I add a red * after the title to the fields I want to be required. I have the following code:

<script type="text/javascript"> 

$(document).ready(function ($) { 

//Strategic Objective
$('nobr:contains("Strategic Objective")').closest('tr').show();
$('nobr:contains("Strategic Objective")').html("Strategic Objective <span class=\"validate\"> *</span>");

//Start Date  
$('nobr:contains("Start Date")').closest('tr').show();
$('nobr:contains("Start Date")')

Mvc JQuery Validation not working with IIS



Im using MVC 2 and .NET 4 on my local machine.   I can debug my project using the Visual Studio Development Server locally.  Everything works great, including the validation using

 <script src="../Scripts/swfobject.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/jquery.validate.min.js"></script>
    <script type="text/javascript" src="../../Scripts/MicrosoftMvcJQueryValidation.js"></script>
The validation doesnt work in any way  if I change to debugging using the Local IIS Web server.
Also, the validation doesnt work in any way on the production web server using IIS.
What am I missing?  What does IIS need (or what does the server need) to make   MicrosoftMvcJQueryValidation.js work?   
MicrosoftMvcJQueryValidation.js is MVC 

JQuery Validation Plugin Error


I have added method in JQuery Validation which is working in FireFox but it is giving error in IE. Can somebody tell what can be the Problem. After adding companyNameCheck method it is giving error.

This is my JQuery Script

        $("#btnValidate").click(function () {
              required: true,
              companyNameCheck: true
             required: "Provide Company Name" ,
             companyNameCheck: "Company already exits"
            success: function (label) {
              // set   as text for IE 
              label.html(" ").addClass("positive");
            errorPlacement: function (error, element) {

      jQuery.validator.addMethod('SelectNone', function (value, element) {
        return this.optional(element) || (value.indexOf("-- Please Select --") == -1);

Server validation is not firing if submited by Jquery $.ajax method


I am new in MVC.Using MVC2.MY create view is given below...

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.ExpenseCategory>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script src="<%=ResolveUrl("~/Scripts/jquery-1.4.1.min.js")%>" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
        function SaveExpenseCategory() {
            try {

                var requrl = "/ExpenseCategory/Create";
                var formID = "frmAddEC";
                var serdata = $(frmAddEC).serialize();


GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

call JavaScript - jQuery code from ASP.NET Server-Side

jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend