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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:42:39+00:00 2026-06-05T21:42:39+00:00

I am loading a primary view that initially renders a Partial view with a

  • 0

I am loading a primary view that initially renders a Partial view with a model that has a required field. As you would expect client validation works on that initial Partial but when I render the same Partial view dynamically using AJAX the client validation fails to recognize the dynamically added fields as unique.

I’m not surprised by this because after all they have the same name, id and validation data-dash attributes but is there a way to get the client validation messages to recognize each field separately without having to manually check and apply client validation in script?

Primary View:

@{Html.EnableClientValidation(); }
@{using (Html.BeginForm()){
    @Html.Partial("_WorkItem")
    <div id="newItemHolder">

    </div>

    <div id="addItem">Add Item</div>
}}

<script type="text/javascript">
  $(document).ready(function () {
    $("#addItem").click(function () {
        $.ajax({
            type: "POST",
            data: {},
            url: "Controller/NewItem",
            success: function (data) {
                //inject partial views content to newItemHolder
                jQuery.validator.unobtrusive.parse($("#newItemHolder"));
            }
        });
    });
  });
</script>
  • 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-05T21:42:40+00:00Added an answer on June 5, 2026 at 9:42 pm

    I found a way to fix this and in case anyone else has this same scenario/issue I’ll include the resolution that I came up with. If anyone has accomplished the goal of validating each partial using client side validation via the data annotations I would definitely be interested to hear how you did it too!

    What I did was to put each partial into a form, that way the validation has unique names on the fields in each form then with some trigger, and eventually with the form submit I called the following.

    $('form').each(function () {
        $(this).validate().form();
    });
    

    The result is that each field that is required is validated on it’s own and when providing a value for one required field it does not cause the client side validation to succeed for all controls that share the same name.

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

Sidebar

Related Questions

It seems that log4j has some class loading issues (among others) and it seems
Loading class (View): public class Loading extends View { private long movieStart; private Movie
I have some code (written by another developer) that is doing AJAX page loading
For a project I need a dynamic way of loading partial views, preferably by
I have disabled interactions in my primary view (which contains some subviews I use
Ok I am finding a problem when loading datatables on a table that's in
Loading images into Flex (size < 100kb) causes IE7 memory increase by a megabyte
When loading the class, using method forName() , any static initializers in the class
On loading the page I want to pass a value to my javascript function
While loading a Windows Form (C#), I'm trying to iterate through all controls. So

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.