如何让 jQuery 和 ModelValidation 与正确的 UIculture 同步?
我正在为克罗地亚公司开发一个应用程序。文化信息是: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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看过 jQuery-Glob 吗?
https://github.com/nje/jquery-glob/
Have you looked at jQuery-Glob?
https://github.com/nje/jquery-glob/