Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7957111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:11:57+00:00 2026-06-04T04:11:57+00:00

I am referring this article: http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-validation.aspx which shows how to create custom annotation in

  • 0

I am referring this article:

http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-validation.aspx

which shows how to create custom annotation in Asp.Net MVC 2. However, the client side validation scripts, especially “MicrosoftMvcJQueryValidation” is not available in Asp.Net MVC4. I read it on one article it is part of Asp.Net Futures project. I want to hook up my client side validation using Jquery. In my project template script’s folder, I see scripts named:

jquery.validate.min.js
jquery.validate.unobtrusive.min.js
jquery.unobtrusive-ajax.min.js

Is there any way I can make use of these existing scripts? or do I have to compulsorily download futures project?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:11:58+00:00Added an answer on June 4, 2026 at 4:11 am

    That article is specific to MVC 2 which used MicrosoftAjax. MVC 4 no longer includes the MS Ajax files as they have been deprecated and the preferred method is to use jquery.

    To verify your settings, make sure these scripts are in your layout

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    

    And these two settings are present in the appSettings section in your web.config file

    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    

    So when you add data annotations to your ViewModels you get client side and server side validation both

    public class MyModel 
    {
        [Required]
        [StringLength(30)]
        public string FirstName { get; set; }
    
        [Required]
        [StringLength(30)]
        public string LastName { get; set; }
    }
    

    In your view just make sure you have code like this

    <div>
        @Html.LabelFor(model => model.FirstName)
    </div>
    <div>
        @Html.TextBoxFor(model => model.FirstName) <br/>
        @Html.ValidationMessageFor(model => model.FirstName)
    </div>
    
    <div>
        @Html.LabelFor(model => model.LastName)
    </div>
    <div>
        @Html.TextBoxFor(model => model.LastName) <br/>
        @Html.ValidationMessageFor(model => model.LastName)
    </div>
    

    Update

    Here’s an example of a custom validator that I have called RateRequiredIfCustomIndexRate
    This is the javascript side of it so that it gets added to jquery validation

    $("document").ready(function () {
    
        var isCustomRateRequired = document.getElementById("IsCustomRateRequired");
    
        isCustomRateRequired.onchange = function () {
            if (this.checked) {
                $('#Rate').attr('disabled', 'disabled');
                $('#Rate').val('');
            }
            else {
                $('#Rate').removeAttr('disabled');
            }
        };
    });
    
    jQuery.validator.addMethod("raterequiredifcustomindexrate", function (value, element, param) {
        var rateRequired = $("#CustomRateRequired").val();
        if (rateRequired && value == "") {
            return false;
        }
        return true;
    });
    
    jQuery.validator.unobtrusive.adapters.addBool("raterequiredifcustomindexrate");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm referring to this article here http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/ In my current application I have two
Referring to this web site http://www.cplusplus.com/reference/std/utility/make_pair/ The std::make_pair has this signature (and possible implementation):
I am referring to this project by Jimmy Bogard: http://www.codeplex.com/AutoMapper The code repository site
From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels: At this level, the specified
I have created a button widget with custom images by referring this article. I
Referring to this question: https://stackoverflow.com/questions/2035449/why-is-oop-hard-for-me class Form { protected $inputs = array(); public function
I'm referring to this article . I'm basically creating a class with an init
How does tension relate to cubic spline interpolation? I am referring to this article
Edited........ sorry Sir I was referring this piece of code from Stephen Toub's article..
I am refering to article at http://www.wintoolzone.com/articles/AuthoringStackWalkerForX86.pdf I am using VC++ 2008. I realize

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.