Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery client side validation not working with MVC 3 MvcContrib.FluentHtml
    primarykey
    data
    text
    <p>Using MVC 3 RTM and MvcContrib/FluentHtml version 3.0.51.0, I can't get the jQuery client side validation to work. Server side validation works fine, and returns showing the correct validation summary, etc. But the form post always tries to hit the server-side post controller action when it should have stopped on the client side to display the validation error.</p> <p>Any ideas of what I'm missing? Could the latest version of MvcContrib/FluentHtml be incompatible with jQuery client validation?</p> <p>Here's my code:</p> <p>Web.config has: </p> <pre><code>&lt;add key="ClientValidationEnabled" value="true"/&gt; &lt;add key="UnobtrusiveJavaScriptEnabled" value="true"/&gt; </code></pre> <p>Site.Master page has:</p> <pre><code>&lt;script src="&lt;%= Url.Content("~/Assets/JavaScript/jquery-1.4.4.min.js")%&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="&lt;%= Url.Content("~/Assets/JavaScript/jquery-ui-1.8.7.min.js")%&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="&lt;%= Url.Content("~/Assets/JavaScript/jquery.validate.min.js")%&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="&lt;%= Url.Content("~/Assets/JavaScript/jquery.validate.unobtrusive.min.js")%&gt;" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>View page inherits from MvcContrib's ModelViewPage: Here's the view page:</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="ModelViewPage&lt;MaintainReferralAgencyDetailVM&gt;" %&gt; &lt;%@ Import Namespace="OASIS3G.Controllers" %&gt; &lt;%@ Import Namespace="OASIS3G.ViewModels" %&gt; &lt;%@ Import Namespace="JCDCHelper.Extension"%&gt; &lt;%@ Import Namespace="MvcContrib.FluentHtml" %&gt; &lt;%@ Import Namespace="System.Web.Mvc" %&gt; &lt;%@ Import Namespace="System.Web.Mvc.Html" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;% using (Html.BeginForm()) %&gt; &lt;% { %&gt; &lt;h1&gt;Referral Agency Detail&lt;/h1&gt; &lt;%= Html.ValidationSummary(false) %&gt; &lt;table class="NoBorder"&gt; &lt;tr&gt; &lt;td class="NoBorder SubmitFormLeftColumn"&gt;&lt;span class="required"&gt;* &lt;/span&gt;Zip Code:&lt;/td&gt; &lt;td class="NoBorder"&gt;&lt;%= this.TextBox(x =&gt; x.ReferralAgency.ContactInformation.Zipcode) %&gt; Example: 99999 or 999990000 &lt;%= Html.ValidationMessageFor(x=&gt;x.ReferralAgency.ContactInformation.Zipcode) %&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="submit" value="Submit" /&gt; &lt;% } %&gt; &lt;/asp:Content&gt; </code></pre> <p>Here's the controller post action:</p> <pre><code>[HttpPost] public ActionResult MaintainReferralAgencyDetail(MaintainReferralAgencyDetailVM userInputs) { // I shouldn't reach this when I submit the form with a blank Zipcode, but I do: if (ModelState.IsValid) { </code></pre> <p>Here's the entity object with the Required field:</p> <pre><code>[Serializable] public class ContactInformationEO { public virtual Int64 AddressId { get; set; } [Required] public virtual string Zipcode { get; set; } </code></pre>
    singulars
    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.
    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