{"id":3584,"date":"2014-03-28T22:50:48","date_gmt":"2014-03-28T22:50:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/28\/asp-net-mvc-3-rc-razor-validationmessagefor-custommessage-and-clientsidevalidation-problem-collection-of-common-programming-errors\/"},"modified":"2014-03-28T22:50:48","modified_gmt":"2014-03-28T22:50:48","slug":"asp-net-mvc-3-rc-razor-validationmessagefor-custommessage-and-clientsidevalidation-problem-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/28\/asp-net-mvc-3-rc-razor-validationmessagefor-custommessage-and-clientsidevalidation-problem-collection-of-common-programming-errors\/","title":{"rendered":"Asp.net MVC 3 RC &#8211; Razor ValidationMessageFor CustomMessage and ClientSideValidation Problem-Collection of common programming errors"},"content":{"rendered":"<p>ASP.Net MVC 3 RC, Razor<\/p>\n<p>Experiencing some unexpected behavior when I try to use a custom message and using client side validation. The problem is it always displays the custom message even though there is no error.<\/p>\n<p>So say I have a Client Model where the FirstName is set as Required. If I have the following code the validation message is not displayed until I click on Submit which works as expected.<\/p>\n<pre><code>@Html.EditorFor(model =&gt; model.Client.FirstName) @Html.ValidationMessageFor(model =&gt; model.Client.FirstName)\n<\/code><\/pre>\n<p>But now say I want to customize the validation message to use an asterisk like so:<\/p>\n<pre><code>@Html.EditorFor(model =&gt; model.Client.FirstName) @Html.ValidationMessageFor(model =&gt; model.Client.FirstName, \"*\")\n<\/code><\/pre>\n<p>Now even before I click on the submit button, there is always an asterisk next to the field.<\/p>\n<p>The expected behavior is that it would show the asterisk when there is a validation error.<\/p>\n<p>Thanks for any help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ASP.Net MVC 3 RC, Razor Experiencing some unexpected behavior when I try to use a custom message and using client side validation. The problem is it always displays the custom message even though there is no error. So say I have a Client Model where the FirstName is set as Required. If I have the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3584","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3584"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3584\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}