Search

ASP.NET MVC 3 and the jquery.validate.unobtrusive.js won't respect culture format by toebens2

Closed
as Fixed Help for as Fixed

22
0
Sign in
to vote
Type: Bug
ID: 645066
Opened: 2/18/2011 2:13:40 AM
Access Restriction: Public
0
Workaround(s)
13
User(s) can reproduce this bug
hello,
there seems to be a bug with MVC 3 and the jquery.validate.unobtrusive.js:

I'm developing a german asp.net mvc 3 website and have included the jquery script:
-jquery-1.4.4.min.js
-jquery.validate.min.js
-jquery.validate.unobtrusive.min.js
in this order.

the web.config has add key="UnobtrusiveJavaScriptEnabled" value="true" (as well as globalization culture="de-DE" uiCulture="de-DE")

if i enter some german formated number like "1,2" into a textbox for a model property (of type double) i get a validation error: "The field THENAMEOFPROPERTY must be a number." ("1.2" is working)

if i disable UnobtrusiveJavaScriptEnabled by setting key="UnobtrusiveJavaScriptEnabled" value="false" in web.config there is no validation error and it is working correctly.

i also tried using the jquery globalization plugin but the jquery validation plugin doesn't seem to use it (please also have a look at http://stackoverflow.com/questions/4472821/asp-net-mvc-3-rc-2-client-side-validation-with-globalization too)

thanks, toebens
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Internationalization

Steps to reproduce

Creating a new asp.net mvc 3 project via the vs2010 template and see my description above

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

gives validation error for entered german formated number "1,2": "The field THENAMEOFPROPERTY must be a number."

"1.2" is passing validation

Expected results

no validation error for german formated number "1,2"

but validation error for non-german formated number "1.2"
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 9/13/2011 at 1:49 PM
Hi everyone,

While ASP.NET MVC doesn't use the jQuery Validate globalization features out of the box, it's quite easy to add the functionality to the sites and apps that you're building.

One of our documentation writers, Rick Anderson, wrote a blog post on how to get this all working:
http://blogs.msdn.com/b/rickandy/archive/2011/02/17/using-mvc-3-with-non-english-locales.aspx
Some of the content is also on MSDN:
http://msdn.microsoft.com/en-us/library/gg674880(v=vs.98).aspx
And our prolific blogger Scott Hanselman wrote an article recently as well:
http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx

We're also looking to make this work better out of the box, but for now these easy solutions should get you started.

Thanks,
The ASP.NET Team
Posted by Microsoft on 2/18/2011 at 2:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.