久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 羞羞视频在线观看 | 欧美一级欧美三级在线观看 | 亚洲va欧美va人人爽午夜 | 青草久久免费视频 | 日本特黄特色aaa大片免费 | 国产高清视频一区 | 孰女乱色一区二区三区 | 中文字幕一区二区三区四区五区 | 久久国产欧美日韩精品 | 97精品国产97久久久久久免费 | 精品二 | 国产97碰免费视频 | 天天久久 | 成人精品国产一区二区4080 | 欧美在线观看一区二区 | 99久久亚洲 | av黄色免费在线观看 | 日韩av在线免费 | 日韩国产高清在线观看 | 精久久久 | 美女视频黄的 | 国产日韩精品在线 | 精彩视频一区二区三区 | 日韩二三区| 精品一区二区三区不卡 | 亚洲成人精品一区 | 久久福利电影 | 男女羞羞免费视频 | 中文字幕在线播放不卡 | 日本精品久久 | 亚洲三级在线观看 | 久久婷婷色 | 最新午夜综合福利视频 | 国产精品国产三级国产aⅴ中文 | 九色av| 欧美日韩高清一区 | 91精品国产综合久久精品 | 一区二区三区免费观看 | 亚洲一区国产精品 | 精品美女视频在线观看免费软件 | 国产精品毛片一区二区在线看 |