Donate

$(...).valid is not a function in ASP.NET MVC 5

I created an ASP.NET MVC 5 simple application with entry forms integrating bootstrap and jQuery validation. Upon testing, the valid() built-in function is not recognized by the browser as stated in the title of this post. After series of investigation, I found out that by default, ASP.NET MVC does not render the jQuery validation scripts by default in _Layout.cshtml. Only jQuery core scripts.

The fix is to render jqueryval validation scripts in _Layout.cshtml. The scripts have already been bundled in the BundleConfig file.
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval") @*code fix*@
@Scripts.Render("~/bundles/bootstrap")

On page load, the scripts are indeed rendered to the browser using chrome dev tools. $(...).valid is not a function in ASP.NET MVC 5

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input