What I need is in English browser when I open website that has another culture and UI (i.e. Sweden) to see the proper decimal separator.
How to archive it?
<input type="number" step="0.1" pattern="[0-9]+([\,][0-9]+)?" min="0" max="5" />
If even I apply any number like "0,1" with the next click of spinner Browser reset it to "0.2" which has a dot instead of comma.
So how to keep proper decimal separator?
Any clue how to fix it with jQuery?
Browsers do not support HTML5 number inputs seperators very well and each users experience would differ based on their computers regional settings. It may not be wise to force the seperator to be a comma.
The only way I can think of is to use javascript. Here is one example using normal input field. Unfortunately you will lose the html5 input attributes associated with number inputs.
var Inputs = document.querySelectorAll('input');
for (var i=0; i<Inputs.length; i++) {
Inputs[i].onblur = function() {
this.value = this.value.replace('.',',');
}
}
function multiplyAndPopulate() {
var A1 = theForm.A1field.value.replace(',','.');
var A2 = theForm.A2field.value.replace(',','.');
var R1 = (A1*A2);
if (isNaN(R1) == true) {
alert('Invalid.');
return false;
}
else {
theForm.R1field.value = R1;
theForm.R1field.value = theForm.R1field.value.replace('.',',');
}
}
<input type="text" pattern="[0-9]+([\,][0-9]+)?" MaxLength="3"/>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments