开发者

Is it possible to change symbol before it's printed with javascript?

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 开发者_Python百科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?


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


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.

http://jsfiddle.net/djgraff209/KpR52/3/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜