Required field validations not working in JQuery Popup MVC 4

前端 未结 1 689
执念已碎
执念已碎 2020-11-22 09:29

I have JQuery popups and i want to put required field validations on it and for this i have set required attributes in model and have also set the validation message for the

相关标签:
1条回答
  • 2020-11-22 10:06

    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.

    0 讨论(0)
提交回复
热议问题