Does anybody know how to change an entered symbol seamlessly with javascript? Because when I just replace an already-printed symbol with the desired one (something like onkeyup="this.value=this.value.replace(/,/g,'.')"), the user sees the replacement occur: you press comma, comma is printed, then it's replaced by a dot. Of course, it happens quickly so it's not a big problem, but anyway I want the dot to be printed immediately without printing and replacing the comma first. Is it possible?
Asked
Active
Viewed 96 times
3 Answers
3
You will have to cancel default event and add the other character to the input manually
Look at this question it should help you: how to insert dot instead of comma in js keypress

Community
- 1
- 1

Jan Pfeifer
- 2,854
- 25
- 35
0
Try using onkeydown instead and stop the event from propagating.
A quick fiddle I did to try this out ... this is quick and dirty and may cause issues.

Dave G
- 9,639
- 36
- 41
-
Use the technique referenced by Jan Pfeifer. It is much more robust than the q&d I did above. – Dave G Oct 07 '11 at 13:01
0
Yes , You have to use javascript event like
1) onkeydown
2) onkeyup
to achieve your task.
So first try yourself .
If you have further problem then you can ask..But First TRY yourself.

Gourav khanna
- 1,381
- 1
- 11
- 15