HTML5 input field with type = "number" does not accept comma in Chrome browser

I am using an HTML5 input field with type="number" . For some documents, you can enter a semicolon (not a period) if I also use the lang="" attribute. It works in Firefox, but not in Chrome (does not accept a comma). How can I get Chrome to accept a comma in an input field. My problem is that our German users expect that they can enter a comma instead of a period there.

https://jsfiddle.net/byte2702/y3Lpfw7m/

 Please enter a number with comma: <br/> <input id="num" type="number" step="any" lang="de" pattern="-?[0-9]+[\,.]*[0-9]+" /> 
+14
input html5 numbers comma
Feb 10 '16 at 12:20
source share
5 answers

At the moment (08/30/2017) Antoine Thiry's answer seems to be more invalid in Chrome (my version is 60.0.3112.113). Unfortunately, I have no other suggestions besides simulating type = "number" with javascript.

+3
Aug 30 '17 at 6:09
source share

in fact, if I read the documentation correctly, pattern not supported for type=number . therefore, stick to type=text , and then add pattern="..." to check the front end. in the next step, you will need to convert the text input to a real number if it is not compatible with JavaScript / computational format.

2017 and there is still no good solution to this common problem ...

+6
Oct 14 '17 at 12:10
source share

I had the same problem, some data was not saved because our users used a comma instead of a period. I found this post that answered your question.

All I added is in my inputs for numbers: lang='en-150'

 <input type='number' lang='en-150'/> 

And it should work in both Chrome and firefox.

0
May 02 '17 at 11:27
source share

At the moment I tried

  <html lang="en"> 

or

  <input type="number" lang="en"> 

and it allowed me to enter any: a comma or a period. I tested it on Ubuntu desktop and Android mobile in Firefox and Chrome.

0
Jan 29 '18 at 19:43
source share

this solution works for me

 <input type="number" value="0.00" min="0" max="10" step="0.01" id="Valore" name="Valore" /> 
-2
Nov 30 '17 at 8:02
source share



All Articles