输入类型编号已翻译

输入类型编号已翻译

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

问题描述

我正在为手机而建.

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

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:

这意味着取决于浏览器来确定什么将最好地满足用户的需求".我想唯一的替代方法是将页面的语言设置为确实将 ٤٤٤ 表示为 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.

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

07-25 16:19