|
I'm trying to get my website to accept international numbers but I'm having difficulty getting it to work if I apply the Range attribute to my model. I read the following in the
globalization tutorial.
Summing up we may globalize our web application by adding just:
<script type='text/javascript' src="@Url.Content("~/Scripts/globalize.min.js")"></script>
@Html.GlobalizationScript()
@Html.JQueryDatePickerGlobalizationScript()
However, this is not enough to have all our validation rules working properly!
In fact the client side code of the RangeAttribute still uses the standard javascript parsing functions for numbers and dates instead
of their globalized counterparts.
The Mvc Controls Toolkit autodetects the gloabalization library used, if any, and uses its parsing functions in all client side validation rules. Therefore,
if we use the Mvc Controls Toolkit the few lines of code I showed before are enough to put in place the globalization of the whole validation library.
I took this to mean that if you use the MVC Controls Toolkit, you can have the Range attribute work with international numbers (such as 4,5 to represent 4 and a half). But I downloaded the
Basic Tutorials Example and added a double property to the ToDo class. Then I added the Range attribute to my property, but although the property displays in the correct #,# format,
there is a validation error when I tab into and out of that text box. So should this work, or did I misunderstand the blog post and this is a known issue?
Thanks.
|