简体   繁体   English

如何将使用“文化”数字格式的输入字符串转换为JavaScript可以理解的内容?

[英]How can I convert an input string that uses 'cultural' number formatting into something JavaScript can understand?

In my ASP.Net web application, I allow the user to enter a value for the weight of a product. 在我的ASP.Net Web应用程序中,我允许用户输入产品重量的值。 The user can be anywhere in the world (I have users from the US, France, GB, China, etc). 用户可以在世界任何地方(我有来自美国,法国,GB,中国等的用户)。

They enter the weight in a number of ways, including: 他们通过多种方式输入重量,包括:

Using 100000.99 as an example 100,000.99 100 000,99 100'000.99 以100000.99为例100,000.99 100 000,99 100'000.99

You see where I am going with this. 你知道我要去哪里。 I am looking for a way to 'cleanse' this input, and format it in such a way that it will be (forgive my ignorance) 'normal'. 我正在寻找一种“清除”此输入,并以使其(原谅我的无知)“正常”的方式对其进行格式化的方法。

Any ideas on how to do this? 有关如何执行此操作的任何想法? Or frameworks? 还是框架?

Thanks in advance! 提前致谢!

I recommend to use UI decorators and validators to allow user of each culture input and see numbers formatted for his culture. 我建议使用UI装饰器和验证器以允许用户输入每种区域性,并查看针对其区域性格式化的数字。 Then you would able to know which culture is used and handle it correctly. 然后,您将能够知道使用哪种文化并正确处理它。 Also you should allow user to select another culture in case you detect it incorrectly. 另外,您应该允许用户选择其他区域性,以防您错误地检测到它。

Please see this link to see how to determine user culture and language 请查看此链接以了解如何确定用户的文化和语言

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在JavaScript中将字符串日期数字转换为datetime? - How can I convert string date number to datetime in JavaScript? 如何将这个javascript类转换为react可以使用的东西? - How can I convert this javascript class to something react can use? javascript:如何将字符串数字转换为 Javascript 中的数字而不删除点后的任何数字? - javascript: How can I convert a string number to number in Javascript without remove any number after dots? 如何将JSON字符串转换为可读的内容? - How can I convert a JSON string to something readable? 有一些关于Javascript继承的东西,我无法理解 - There is something about Javascript inheritance that I can't understand Javascript的map函数的代码中有些我看不懂的地方 - There is something I can't understand in the code of the map function of Javascript 如何将javascript中的日期转换为字符串 - how can i convert a date in javascript to string 如何在 JavaScript 中将字符串转换为 boolean? - How can I convert a string to boolean in JavaScript? 如何将字符串转换为 JavaScript 数组? - How can I convert a string to a JavaScript array? 如何在 Javascript 中将字符串转换为 object? - How can I convert a string to object in Javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM