0

Implementation Detail:

  • Page has Add Button and Table view
  • On Add button click, partial view (form) is loaded on Modal PopUp. Dynamic form selected based on parameter.
  • On Add button click below code is used to bind the partial view form to div

    $.ajax({
                url: '/Controller/GetModal',
                data: { modalType: modalType },
                success: function (data) {
                    $('#modalWrapper').html(data);
                    $('.modal-wrapper').modal();
                     }
               });

  • Partial View Form implemented using

    Ajax.BeginForm("Save", "Controller",new AjaxOptions
                        {
                            HttpMethod = "POST",
                            UpdateTargetId = "divTableView",
                            LoadingElementId = "loading"
                        }))

Issue : - On Click of save validation is not getting triggered.

Other Information :

Script Files:

bootstrap.js
 jQuery-3.5.1.js
 jquery.unobtrusive-ajax.js
 jquery.validate.js
 jquery.validate.unobtrusive.js

I Have tried adding below code in ajax success method


    $.validator.unobtrusive.parse(form);

Got Below Error:


    $.validator is undefined

Thanks In Advance for help.

Sridhar
  • 453
  • 3
  • 14
  • Check in network if all files are loaded. – Code_Crash Jun 06 '20 at 16:44
  • yes all files are loaded : bootstrap.js, jquery-3.5.1.js, jquery.unobtrusive-ajax.js, jquery.validate.js, jquery.validate.unobtrusive.js,modernizr-2.6.2.js, respond.js - in this order they are displyed – Sridhar Jun 08 '20 at 04:55
  • If all files are loaded, then probably you are trying to access $.validator before got loaded, can you try to run your code after window.onload event? https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onload – Code_Crash Jun 08 '20 at 06:54

0 Answers0