How to handle floats and decimal separators with html5 input type number

后端 未结 10 798
情话喂你
情话喂你 2020-11-27 11:15

Im building web app which is mainly for mobile browsers. Im using input fields with number type, so (most) mobile browsers invokes only number keyboard for better user exper

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 11:47

    Sounds like you'd like to use toLocaleString() on your numeric inputs.

    See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString for its usage.

    Localization of numbers in JS is also covered in Internationalization(Number formatting "num.toLocaleString()") not working for chrome

提交回复
热议问题