MVC 5 JQuery Validate and unobtrusive - Unable to get property 'normalizer' of undefined or null reference

0

I'm using jquery.validate.min.js and jquery.validate.unobtrusive.min.js in an MVC 5 app.

I'm trying to validate in a modal form. The Fields are not model bound. I’m having an issue with unobtrusive validation. I get this error.

Unhandled exception at line 779, column 4 in http://localhost:60667/Scripts/jquery.validate.js 0x800a138f - JavaScript runtime error: Unable to get property 'normalizer' of undefined or null reference.

It occurs in the ChartEditModal.

   function OnChartSave()
   {
         if (OnChartSave.caller == null) return false;

         // Reset jQuery Validate's internals (resets the inputs)
         formValidator.resetForm();

         if (!formValidator.element("#TitleDetail")) return;
   }

   $(document).ready(function ()
   {
         // Initialise form validator
         formValidator = $("#dashboardForm").validate();

         $("#TitleDetail").rules("add",
         {
                required: true,
                messages: { required: "A title must must be specified" }
         });
   });

The markup:

<div class="col-md-4">
    <div class="form-group preventWrappingClass">
       @Html.Label("Title", htmlAttributes: new { @class = "control-label col-md-4 labelForStyling" })
       <div class="col-md-12">
          @Html.Editor("TitleDetail", new { htmlAttributes = new { @class = "form-control pull-left", @id = "TitleDetail" } })
          @Html.ValidationMessage("TitleDetail", "", new { @class = "text-danger" })
      </div>
   </div>
</div>

And the Parent is

<form id="dashboardForm">

And in the parent script.

   var formValidator = null;  

I’ve tried re-arranging the order of the script references, removing some, trying with Layout = null.

And

@Scripts.Render("~/Scripts/Chart.min.js")
@Scripts.Render("~/Scripts/utils.js")
<link href="~/Content/Site.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/jquery-3.5.1.js"></script>
<link href="~/Content/Chart.min.css" rel="stylesheet">
<script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
<link href="~/Content/DataTables/css/jquery.dataTables.css" rel="stylesheet" />
<script src="~/Scripts/DataTables/jquery.dataTables.js"></script>
<script src="~/scripts/jquery.validate.min.js"></script>
<script src="~/scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/Site.js"></script>

Edge and chrome give me :

"Cannot read jquery.validate.js:779 property 'normalizer' of undefined at $.validator.check

Any ideas please?

Thx

jquery
validation
asp.net-mvc-5
unobtrusive-validation
asked on Stack Overflow Mar 11, 2021 by Neal Rogers • edited Mar 11, 2021 by Neal Rogers

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0