输入类型编号已翻译 [英] Input type number translated

查看:51
本文介绍了输入类型编号已翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为手机而建.

我有一个包含输入类型编号的表格.将设备语言设置为阿拉伯语时,只要我为此输入设置值,就会以阿拉伯数字显示.

I have a form that includes an input type number. When the device language is set to Arabic whenever I set a value to this input it will show it in Arabic numbers.

如果我做这样的事情:

document.getElementById('input-id').value = 444

document.getElementById('input-id').value = 444

在用户界面中,我们可以看到输入的值为 ٤٤٤ ,相当于阿拉伯数字444.

In the UI, we can see the input will have a value of ٤٤٤, this is the equivalent to 444 in Arabic numerals.

在输入type ="text"中,我没有这个问题,因为它显示了一个字符串字符串,所以不会转换它们.

I don't have this issue in Input type="text" because it shows an String of characters so it doesn't convert them.

我知道我可以改用Input类型的文本,但是我想保持与我的应用程序其余部分的一致性,并使用Input类型的数字

I know that I could use an Input type text instead but I would like to keep the consistency with the rest of my application and use an Input type number

我在 Chrome Safari Firefox 中遇到此问题.

I have this issue in Chrome, Safari and Firefox.

说明:我不希望将其翻译成阿拉伯数字.我该怎么做?

Clarification: I don't want it to translate it to Arabic Numerals. How can I make this?

推荐答案

HTML规范的数字" 输入类型状态部分中的部分:

The HTML specification's section on the Number input type states:

注意::该规范未定义用户代理要使用的用户界面;鼓励用户代理供应商考虑最能满足其用户需求的产品.例如,波斯或阿拉伯市场中的用户代理可能支持波斯和阿拉伯数字输入(如上所述将其转换为提交所需的格式).同样,为罗马人设计的用户代理可能会用罗马数字而不是十进制显示值.或者(更现实的是)为法国市场设计的用户代理可能会在小数点前显示带有千分号和逗号之间的撇号的值,并允许用户以这种方式输入值,并将其内部转换为上述提交格式./p>

Note: This specification does not define what user interface user agents are to use; user agent vendors are encouraged to consider what would best serve their users' needs. For example, a user agent in Persian or Arabic markets might support Persian and Arabic numeric input (converting it to the format required for submission as described above). Similarly, a user agent designed for Romans might display the value in Roman numerals rather than in decimal; or (more realistically) a user agent designed for the French market might display the value with apostrophes between thousands and commas before the decimals, and allow the user to enter a value in that manner, internally converting it to the submission format described above.

这意味着取决于浏览器来确定什么将最好地满足用户的需求".我想唯一的替代方法是将页面的语言设置为确实将 ٤٤٤ 表示为 444 的语言(例如英语).为此,我们只需:

This implies that it's down to the browser to determine what would "best serve their users' needs". I imagine the only way to override this would be by setting the language of your page to a language which does represent ٤٤٤ as 444 (such as English). To do this, we simply:

<body lang="en">

不过,这完全取决于浏览器来决定是否遵守.

However, again, this is entirely down to the browser to decide whether to adhere to this.

这篇关于输入类型编号已翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆