html tag input of type=”number” and culture based decimal separator

DmitryBoyko

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?

DreamTeK

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Decimal dot and thousands separator used both in input type number

From Dev

Typed decimal disappears from HTML text input of type 'number' in browser

From Dev

html5 input[type=number] two decimal points

From Dev

decimal? type is not culture specific

From Dev

Input type number, decimal value

From Dev

How to format number with "." as thousand separator, and "," as decimal separator?

From Java

Allow 2 decimal places in <input type="number">

From Dev

Firefox - input type number hides decimal places

From Dev

HTML input tag, cannot type

From Dev

How to convert number into decimal with shifted decimal separator?

From Dev

Change CSS of input number type based on input

From Dev

Change CSS of input number type based on input

From Dev

django templates decimal separator with safe tag

From Dev

Vertical alignment on an html input tag of type color

From Dev

Remove grouping separator from a decimal number in Android

From Dev

Jaxb conversion of number with comma as a decimal separator

From Dev

Format a number to always have a sign and decimal separator

From Dev

Format BigDecimal or Number without Decimal Separator

From Dev

Number with decimal separator incorrectly cast to Double

From Dev

Number Format with Thousands Separator and Decimal if Necessary

From Dev

Convert a number and accept any decimal separator

From Dev

Format BigDecimal or Number without Decimal Separator

From Dev

Angular2 input type number, no decimal value

From Dev

Angular2 input type number, no decimal value

From Dev

Center Text QML type based on the dot of a decimal number

From Dev

Number with decimal input in React?

From Java

HTML5 Number Input - Always show 2 decimal places

From Dev

HTML5 input: Whole number step with decimal min

From Dev

HTML 5 Number Input with MVC doesn't show decimal

Related Related

  1. 1

    Decimal dot and thousands separator used both in input type number

  2. 2

    Typed decimal disappears from HTML text input of type 'number' in browser

  3. 3

    html5 input[type=number] two decimal points

  4. 4

    decimal? type is not culture specific

  5. 5

    Input type number, decimal value

  6. 6

    How to format number with "." as thousand separator, and "," as decimal separator?

  7. 7

    Allow 2 decimal places in <input type="number">

  8. 8

    Firefox - input type number hides decimal places

  9. 9

    HTML input tag, cannot type

  10. 10

    How to convert number into decimal with shifted decimal separator?

  11. 11

    Change CSS of input number type based on input

  12. 12

    Change CSS of input number type based on input

  13. 13

    django templates decimal separator with safe tag

  14. 14

    Vertical alignment on an html input tag of type color

  15. 15

    Remove grouping separator from a decimal number in Android

  16. 16

    Jaxb conversion of number with comma as a decimal separator

  17. 17

    Format a number to always have a sign and decimal separator

  18. 18

    Format BigDecimal or Number without Decimal Separator

  19. 19

    Number with decimal separator incorrectly cast to Double

  20. 20

    Number Format with Thousands Separator and Decimal if Necessary

  21. 21

    Convert a number and accept any decimal separator

  22. 22

    Format BigDecimal or Number without Decimal Separator

  23. 23

    Angular2 input type number, no decimal value

  24. 24

    Angular2 input type number, no decimal value

  25. 25

    Center Text QML type based on the dot of a decimal number

  26. 26

    Number with decimal input in React?

  27. 27

    HTML5 Number Input - Always show 2 decimal places

  28. 28

    HTML5 input: Whole number step with decimal min

  29. 29

    HTML 5 Number Input with MVC doesn't show decimal

HotTag

Archive