Validation not working on partial views

I have a root view with two partial views that get loaded into divs based on a button click:

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
    <legend>Donation information</legend>
    <p>
        @Html.LabelFor(m => m.DonationType.DonationTypex) <br />
        @Html.DropDownListFor(model => model.DonationType.DonationTypeID, ViewBag.DonationTypes as      
        SelectList, htmlAttributes: new { @id = "selectList" })
        &nbsp;&nbsp;
        @Html.ActionLink("Select", "ContinueDonation", "Donation", htmlAttributes: new { @id = 
        "btnSelect1" })

    </p>

    <div id="donationSection1"></div>

 <br />
 <input id="btnAddPayment1" type="button" value="Add Payment Info" />
 <br /><br />
 <div id="paymentSection1"></div>

 <input type="submit" id="btnSubmitDonation" value="Save" />
 <input type="button" id="btnCancelDonation" value="Cancel" /> 

 </fieldset>
}

The partial views that are loaded into the donationSection1 and paymentSection1 divs share the same Model, just contain editors, labels etc for different properties within it... just wondering how I can get it to validate the partial views... if the submit/save button is on the root view...

...jquery that loads div... (controller returns partial view sharing same model):

  $("#btnSelect1").click(function () {
        var donationTypeID = $(this).closest('p').find('#selectList').val();
        var id = parseInt(donationTypeID);
        var route = '/Donation/ContinueDonation?dTypeId=' + id;
        $("#donationSection1").load(route, function () {
            $("#donationSection1").show('slow');
        });
        return false;
    });

Answers


try using jquery validator.unobtrusive.parse

$("#btnSelect1").click(function () {
        var donationTypeID = $(this).closest('p').find('#selectList').val();
        var id = parseInt(donationTypeID);
        var route = '/Donation/ContinueDonation?dTypeId=' + id;
        $("#donationSection1").load(route, function () {
            $("#donationSection1").show('slow');
        });
          jQuery.validator.unobtrusive.parse('#donationSection1')
        return false;
    });

here is the link with more explanations

http://itmeze.com/2010/10/08/client-side-validation-after-ajax-partial-view-result-in-asp-net-mvc-3/


Need Your Help

compare two decimal values with specific range in perl

perl decimal

I am new to Perl. I have two different sets of arrays. Those two arrays having decimal values, both does not have an exact matches, it might be differ only either +0.5 or -0.5. I tried this program...

How to set cursor position in softkeyboard(not in EditText or TextView!!!) in Android?

android android-softkeyboard cursor-position soft-keyboard

The following code works for only 1000 characters. If there are more than 1000 characters, the cursor will jump back to the end of 999 characters and start working again.