When user entering 123456 , user will look 123.456
in the input field.
I used my code but this display 123,456
What i want is exactly that Thousand separator is dot (not comma)
My code in link https://jsfiddle.net/bvotcode/tym4qf2r/3/
< form> <label for="ticketNum">Your money</label> <input type="text" oninput="sepratornumberwithdot(this)" placeholder="123.456.789"/> < /form>
function sepratornumberwithdot(input) {let nums = input.value.replace(/,/g, '');if (!nums || nums.endsWith('.')) return;input.value = parseFloat(nums).toLocaleString();}
I tried using Javascript to adjust to dot but didn’t work. Any help would be appreciated.
Thanks!
2
Answers
Normally we use toLocaleString() with one’s country code, like this:
And so forth…
But if you’re not happy use the German which does dots!
Change your first regular expression to /[,.]/g so that you get rid of commas and periods.
Add .replace(/,/g, ‘.’) to the end of your .toLocaleString()
That will do it. See code snippet below: