久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

輸入類型編號的本地化

Localization of input type number(輸入類型編號的本地化)
本文介紹了輸入類型編號的本地化的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在一個在 Chrome 中運行的 Web 應用程序上工作,我有輸入類型為 number.在我的語言環境中,逗號用于十進制數字,空格用于千位分隔(不是那么重要),但是當我將這些字符輸入數字字段時,它們會被簡單地刪除,從而有效地將金額增加了 100.

I work on a web application running in Chrome, where I have inputs with type number. In my locale commas are used for decimal numbers and a space is used for thousand separation (not that important), but when I enter these characters into a number field, they are simply removed, effectively increasing money amounts by a hundred.

我已經在瀏覽器設置和頁面上設置了語言,但我仍然需要使用句點來表示小數.有什么方法可以配置該字段以接受逗號?

I have set the language both in the browser settings and on the page, but I still need to use a period for decimals. Is there any way I can configure the field to accept commas?

或者,我將不得不使用 javascript 來解決這個問題.我想我可以處理 keydown 事件并在用戶鍵入時將逗號更改為句點,但這不會提供很好的用戶體驗,不是嗎?那么如何在我的代碼中以最小的占用空間實現這一目標呢?

Alternatively, I'll have to solve this using javascript. I guess I could handle the keydown event and change commas to periods as the user types, but that wouldn't give a great user experience, would it? So how can I acheive this with a minimal footprint in my code?

推薦答案

HTML5 input type=number 從本地化的角度來看是不夠的,因為定義和實現都有.它應該是本地化的,但要根據 瀏覽器 的區域設置,您無法設置甚至不知道作為設計者/作者.

The HTML5 input type=number is inadequate from the localization point of view, due to both the definition and the implementations. It is meant to be localized but as per the locale of the browser, which you cannot set or even know as a designer/author.

在我的 Chrome 上,input type=number step=0.001 接受 1,2(帶逗號)并將其作為 1.2 發送,它接受 1.200(帶句點),明顯將其轉換為 1200并像這樣發送.當瀏覽器區域設置為芬蘭語時,或多或少就是這樣.但它無法接受 1200(這是芬蘭語中 1200 的標準書寫方式),而是只發送數字 1.

On my Chrome, the input type=number step=0.001 accepts 1,2 (with comma) and sends it as 1.2 and it accepts 1.200 (with a period), visibly converting it to 1200 and sending as such. This is how things are meant to be, more or less, when the browser locale is Finnish. But it fails to accept 1 200 (which is standard way of writing 1200 in Finnish) and instead sends just the digit 1.

所以這是相當絕望的.使用您能找到的任何 JavaScript 小部件,或簡單的文本輸入框.任何東西都可能比 input type=number 更好,除非所有用戶都使用具有相同語言環境的瀏覽器并且對數字格式有相同的期望.

So it’s rather hopeless. Use whatever JavaScript widgets you can find, or a simple text input box. Anything is probably better than input type=number unless all users use browsers with the same locale and have the same expectations on the format of numbers.

這篇關于輸入類型編號的本地化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 久久久久亚洲精品 | 在线观看国产视频 | 日韩精品一区二区三区免费视频 | 国产精品自产拍在线观看蜜 | 亚洲精品免费视频 | 亚洲欧美在线观看 | 亚洲国产黄色av | 日本不卡免费新一二三区 | www.成人.com| 国产在线一区二区 | 精品日韩一区二区三区av动图 | 色综合色综合网色综合 | 午夜一级做a爰片久久毛片 精品综合 | 中文字幕亚洲一区二区va在线 | 日韩国产一区 | 免费精品 | 欧美中文字幕一区二区三区亚洲 | 日日夜夜av| www.久久.com | 亚洲精品一区av在线播放 | 欧美一区二区二区 | 国产精品高清在线 | 国产激情亚洲 | 久久久久国色av免费观看性色 | av先锋资源| 亚洲精品日本 | 精品国产一区久久 | 色婷婷国产精品 | 四虎影院免费在线播放 | 一区二区视频在线观看 | 日韩精品成人免费观看视频 | 亚洲精品一区在线观看 | 亚洲久久| 日日噜噜噜夜夜爽爽狠狠视频, | 一级看片免费视频囗交动图 | 国产精品久久久久久久久久免费看 | 91精品久久久久久久久99蜜臂 | 老外几下就让我高潮了 | 免费1区2区3区 | 91网在线观看 | 亚洲精品国产a久久久久久 中文字幕一区二区三区四区五区 |