Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 3 jQuery Validation/globalizing of number/decimal field
    text
    copied!<p>When using globalization culture="da-DK" in the Web.config file, the jQuery validation does not work.</p> <p>In Denmark, we use the notation 19,95 instead of the US way 19.95 when we write a price for at product, and that have given me a problem, that I can't solve.</p> <p>I've started VS2010, new MVC 3 project, added a homeController, a Product class, and a simple standard edit view and the error is already there.</p> <p><strong>Product Class:</strong></p> <pre><code>public class Product { public string name { get; set; } public string itemNo { get; set; } public decimal price { get; set; } } </code></pre> <p><strong>HomeController:</strong></p> <pre><code>public class homeController : Controller { public ActionResult Index() { var product1 = new Product { name = "Testproduct", itemNo = "PRD-151541", price = 19 }; return View(product1); } } </code></pre> <p><strong>Index View:</strong></p> <pre><code>@model WebUI.DomainModel.Product &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.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; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Product&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;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.itemNo) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.itemNo) @Html.ValidationMessageFor(model =&gt; model.itemNo) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.price) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.price) @Html.ValidationMessageFor(model =&gt; model.price) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Save" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } </code></pre> <p>The result:</p> <p>Unfortunately I can't submit an image here - so please follow this link to see the result: <a href="http://www.designvision.dk/temp/mvc3_razor_validation_error.gif" rel="noreferrer">http://www.designvision.dk/temp/mvc3_razor_validation_error.gif</a></p> <p>SO - when running the website, the field will be set to 19,00 - which IS the correct culture definition - but when trying to save, validation fails.</p> <p>Please help...</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