Search code examples
androidiphonehtmlwindows-phone-8input

Html5 input type number formatting


I have this page where i use the input type number. so that it will show the numeric keyboard on wp, android and ios device .

But my problem is that if the user use a culture info on the device for. lets say Denmark. the numeric keyboard shown use , instead of .

But the input number won't accept , only . Anyone got a idea how this can be done?

Thanks for your time.


Solution

  • When retrieving the value with jquery it is returned with a . decimal separator. Try this:

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
      <meta charset="utf-8">
      <title>JS Bin</title>
    </head>
    <body>
      <input type="number" name="myNum" id="myNum">
      <button id="submit">Submit</button>
      <hr/>
      <code></code>
      <script>
        $("#submit").on("click",function() {
          var numericValue = $("#myNum").val();
          $("code").html(numericValue);
        });
      </script>
    </body>
    </html>
    

    http://output.jsbin.com/xixunewowe