Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy "Uncaught TypeError: Object [object Object] has no method 'validate' " when I have included jquery.validate.js
    primarykey
    data
    text
    <p>My code:</p> <pre><code>@model ColumnVM @{ ViewBag.Title = "AddColumn3"; Layout = "../Shared/_layout2.cshtml"; } &lt;script type="text/javascript"&gt; $(function () { $("form").validate().settings.submitHandler = function (form) { alert('valid form'); form.submit(); }; }); &lt;/script&gt; @using (Html.BeginForm("addcolumn3", "Course", FormMethod.Post)) { &lt;fieldset&gt; &lt;legend&gt;ColumnVM&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Name) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Name) @Html.ValidationMessageFor(model =&gt; model.Name) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } &lt;div&gt; @Html.ActionLink("Back to List", "Index") &lt;/div&gt; </code></pre> <p>in _Layout2.cshtml</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;@ViewBag.Title&lt;/title&gt; &lt;link href="@Url.Content("~/Content/Layout.css")" rel="stylesheet" type="text/css" /&gt; &lt;script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; @RenderBody() &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now the browser show the error: Uncaught TypeError: Object [object Object] has no method 'validate'. If I change the Layout=null,and add manually in the code</p> <pre><code>&lt;script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>It works!I don't know why.Anybody who knows?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload