如何让 jQuery 和 ModelValidation 与正确的 UIculture 同步?

发布于 2024-12-17 12:47:31 字数 620 浏览 1 评论 0原文

我正在为克罗地亚公司开发一个应用程序。文化信息是:hr-HR 在我的 web.config 中,我设置了:

    <globalization fileEncoding="utf-8" 
                   requestEncoding="utf-8" 
                   responseEncoding="utf-8" 
                   culture="hr-HR" 
                   uiCulture="hr-HR" />

并且十进制数字的值显示正确,即使用逗号作为小数分隔符的正确格式。 22,50 相当于 en-US 22.50

我的问题是,jQuery 验证仍然需要我输入 22.50 才能将其识别为十进制数字,如果我这样做,则该值不会被解析为小数,该模型在应用中无效。

我的问题是,有没有一种简单的方法可以将 jQuery 切换到特定文化进行验证?没有实施国际化等等。

目前,我可以通过读取 FormCollection 值并手动解析它们来解决问题,但这并不是一个很好的解决方案。我还可以将整个应用程序设置为 en-US 文化,但这也不是真正的解决方案,只是一个解决方案。

谢谢

I am working on an application intended for Croatian firm. culture info is: hr-HR
in my web.config i have set:

    <globalization fileEncoding="utf-8" 
                   requestEncoding="utf-8" 
                   responseEncoding="utf-8" 
                   culture="hr-HR" 
                   uiCulture="hr-HR" />

And the values for, lets say decimal numbers are displayed correctly, that is in correct format that uses comma as decimal separator. 22,50 is hr-HR equivalent for en-US 22.50

My problem is, that jQuery validation still requires me to type in 22.50 for it to be recognized as decimal number, and if i do so then in the value does not get parsed as a decimal and the model is not valid in application.

My question is, is there a simple way to switch jQuery to certain culture for validation? Without implementing the internationalization and so on.

For now, i can solve the problem by reading FormCollection values, and parsing them manually, but that is not really a nice solution. I can also set the whole application to en-US culture but that also is not really a solution, just a fix.

Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天暗了我发光 2024-12-24 12:47:31

你看过 jQuery-Glob 吗?

https://github.com/nje/jquery-glob/

Have you looked at jQuery-Glob?

https://github.com/nje/jquery-glob/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文