Required field validations not working in JQuery Popup MVC 4

The validator is parsed when the page is initially loaded. When you add dynamic content you need to reparse the validator. Modify your script to include the following lines after the content is loaded

$(this).load(actionURL, function (html) {
    // Reparse the validator
    var form = $('form');
    form.data('validator', null);
    $.validator.unobtrusive.parse(form);
    $('form', html).submit(function () {
        ....

Side note: The code you have shown does not include @Html.ValidationMessageFor(m => m.MaterialCode) but I assume this is included.

Leave a Comment