Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC Razor Validation not firing on textarea
    text
    copied!<p>i am having a problem with validating a form in MVC Razor the Binding class is the following based off an abstract class (there is no validation in the abstract class) </p> <pre><code>[GeminiDisplayName("You are about To reject the following Purchase Order", false)] public class PORejected : PoApprovalItems { public PORejected() { } [GeminiDisplayName("Rejection Reason")] [Required(AllowEmptyStrings = false, ErrorMessage = "Rejection Reason is Required")] public string RejectReason { get; set; } public override bool IsApproved { get { return false; } } } </code></pre> <p>and the view is as follows</p> <pre><code>@model Gemini.Models.PORejected @section Head{ &lt;script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/PageScripts/_Approval.js")" type="text/javascript"&gt;&lt;/script&gt; } @section TabHeader{ &lt;li&gt;&lt;a href="#ApprovalItem"&gt;Reject Approval for PO @Model.PO_Number&lt;/a&gt;&lt;/li&gt; } @section TabContent{ @{ Html.EnableClientValidation(); } &lt;div id="ApprovalItem"&gt; @{ @Html.ValidationSummary(false) using (Html.BeginForm("Approve", "PO", FormMethod.Post)) { @Html.Partial("Approval/ApprovalDetails", Model) &lt;div class="display-label"&gt; &lt;table width="100%" cellpadding="0" cellspacing="0" border="0"&gt; &lt;tr&gt; &lt;td width="15%"&gt; @Html.LabelFor(x =&gt; x.RejectReason) &lt;/td&gt; &lt;td&gt; @Html.TextAreaFor(x =&gt; x.RejectReason, new { @Class = "mceEditor required", @style = "width:60%;" }) @Html.ValidationMessageFor(x =&gt; x.RejectReason) &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div style="float: right;"&gt; &lt;input type="button" value="Close" /&gt; &lt;input type="submit" value="Reject" /&gt; &lt;/div&gt; &lt;/div&gt; Html.EndForm(); } } &lt;/div&gt; } </code></pre> <p>the thing is when i click the submit button it fires off before doing any validation even though it should validate</p> <p>my question is what am i doing wrong?</p> <p><strong>UPDATED</strong> found the answer eventually i was missing the following from the page. <code>&lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"&gt;&lt;/script&gt;</code></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