Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc 3.0 client validation not working
    text
    copied!<p>This is the code in my partial view - </p> <pre><code>@using (Ajax.BeginForm("SaveLayout", new AjaxOptions { HttpMethod = "Post"})) { @Html.ValidationSummary(true) &lt;div style="padding: 10px;"&gt; &lt;div class="editor-field"&gt; Layout Name: @Html.EditorFor(m =&gt; m.Name) @Html.ValidationMessageFor(m =&gt; m.Name)&lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;input type="submit" value="Save" /&gt; &lt;input type="button" onclick="CloseDialog()" value="Cancel" /&gt; &lt;/div&gt; } </code></pre> <p> in my _Layout.cshtml looks like this - </p> <pre><code>&lt;script src="@Url.Content("~/Scripts/JQuery/jquery-1.6.4.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/JQuery/jquery-ui.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/JQuery/jquery.unobtrusive-ajax.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/JQuery/jquery.validate.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/JQuery/jquery.validate.unobtrusive.js")" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>i have this in my root web.config -</p> <pre><code>&lt;add key="ClientValidationEnabled" value="true"/&gt; &lt;add key="UnobtrusiveJavaScriptEnabled" value="true"/&gt; </code></pre> <p>this is how my controller action looks like - </p> <pre><code>[HttpPost] public ActionResult SaveLayout(Model.Layout layout) { if (ModelState.IsValid) { ILayout.SaveLayout(layout); } return PartialView("_SaveLayout", layout); } </code></pre> <p>and rouhgly this is my model - </p> <pre><code>public class Layout : BaseModel { [Required(ErrorMessage = "Please assign name to the compare group.")] public string Name { get; set; } } </code></pre> <p>I cannot get my client side validation working when the name field is empty and user hits save button. Could someone please suggest what am i doing wrong here? Any help would be greately appreciated.</p>
 

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