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 6699509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:42:13+00:00 2026-05-26T06:42:13+00:00

According to this definition here : Unobtrusive JavaScript avoids injecting inline JavaScript into HTML.

  • 0

According to this definition here:

Unobtrusive JavaScript avoids injecting inline JavaScript into HTML. This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries.

However when reading this blog:
The blogger says:
Now for performing validation eagerly, i.e, performing validation each time when users fields focus out, you need to add this script at bottom of the page.

I dont know if I am confused, but for me Unobstrusive javascript validation means in simple words, NO JAVASCRIPT code on the page, only the references to the .js files that have the logic. In that way you separate the validation logic from the presentation.

With this said, I would like to enable unobstrusive validation in my following form. The only difference I see is:
1. Line 1: I dont have it.

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<EagerlyPerformingValidation.Models.UserInformation>
  1. I should add the jquery logic to a external javascript file and reference it.

Am I missing something here??

public class Position{

            [DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.Identity)]   
            public int PositionID { get; set; }

            [Required(ErrorMessage = "Position name is required.")]
            [StringLength(20, MinimumLength = 3, ErrorMessage = "Name should not be longer than 20 characters.")]
            [Display(Name = "Position name")]              
            public string name { get; set; }

            [Required(ErrorMessage = "Number of years is required")] 
            [Display(Name = "Number of years")]
            [YearsValidationAttribute(5, ErrorMessage = "{0} value must be greater than {1} years.")]        
            public int yearsExperienceRequired { get; set; }

            public virtual ICollection<ApplicantPosition> applicantPosition { get; set; }
        }




@model Data.Model.Position

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<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>

    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>Position</legend>

            <div class="editor-label">
                @Html.LabelFor(model => model.name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.name)
                @Html.ValidationMessageFor(model => model.name)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.yearsExperienceRequired)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.yearsExperienceRequired)
                @Html.ValidationMessageFor(model => model.yearsExperienceRequired)
            </div>

            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>
    }

    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
  • 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-05-26T06:42:14+00:00Added an answer on May 26, 2026 at 6:42 am

    The unobtrusive validation done according to your (correct) understanding is kind of “lazy” in that it only fires when you submit the form. The javascript code referenced by the blog post you linked to simply causes the validation to fire each time you tab out of a control. You’re right that it’s not really unobtrusive javascript as presented.

    I think the way you could make it be unobtrusive is either to add data- attributes to each control (a pain) and write code to inject the script, or to add his little bit of script to one of the main javascript files you are referencing, which is probably his intention.

    There is a cool bit about this in chapter 8 of this book: Wrox Professional ASP.NET MVC 3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this http://perldoc.perl.org/UNIVERSAL.html I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i
According to the XML spec, this is the definition of an empty element: An
According this MSDN article HttpApplication .EndRequest can be used to close or dispose of
According to this discussion , the iphone agreement says that it doesn't allow loading
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when
According to this page, it's possible to use TClientDataset as an in-memory dataset, completely
According to this article rebasing is not necessary for .NET assemblies due to JIT
According to this site I can simply write $user = getlogin(); but the group
According to this website , you can change to command key sequence used by

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.