How to handle number input with locale-specific formatting in JavaScript without external libraries?

I want users to enter numbers and currency values in an input field using their own locale-specific formatting. For example:

  • In the Netherlands: 1.234,56 for one thousand two hundred thirty-four and 56 cents.
  • In the US: 1,234.56 for the same value.

The input should be displayed exactly as entered by the user, but I need to normalize this value in JavaScript (e.g., convert it to a standard format like 1234.56 for backend processing). Ideally, this should work automatically based on the user’s locale, but if necessary, I can ask them to specify their preferred format beforehand.

I’m looking for a simple and elegant solution—preferably something that’s already built into JavaScript since this seems like a common issue many developers might face. I would like to avoid large code blocks or complex solutions. Any guidance on how to achieve this efficiently would be appreciated.