[英]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.