How to force to display a number with a comma with input type number?

后端 未结 1 839
北荒
北荒 2021-01-14 04:30

I have this input type number:


Of course the value is a number, how to force it to display a number with a co

相关标签:
1条回答
  • 2021-01-14 05:09

    You can use the french locale lang="fr" that use a comma for the decimal separator.

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8">
        <title>Input test</title>
        <script>
          function init(){
            document.getElementById('in1').value = 3.14;
          }
        </script>
      </head>
      <body onload="init()">
        <input id="in1" lang="fr" type="number">
      </body>
    </html>
    

    It works well with Firefox 39.0:

    but unfortunately it's not yet implemented in Chrome 44.

    0 讨论(0)
提交回复
热议问题