469,284 Members | 2,519 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,284 developers. It's quick & easy.

change comma to point in real-time?

Is it any way to change comma to point when it is typped into the INPUT
field?
Jul 23 '05 #1
5 20612
"Piotr" <pi**@gaztea.pl> wrote in message
news:nr****************************@40tude.net...
Is it any way to change comma to point when it is typped into the INPUT
field?


Will this help? Watch for word-wrap.

<html>
<head>
<title>comadot.htm</title>
<script type="text/javascript">
function commadot(that) {
if (that.value.indexOf(",") >= 0) {
that.value = that.value.replace(/\,/g,".");
}
}
</script>
</head>
<body>
<form>
<input type="text" name="txt" onkeyup="commadot(this)">
</form>
</body>
</html>
Jul 23 '05 #2
it's this, thank you!
Jul 23 '05 #3
McKirahan wrote on 12 dec 2004 in comp.lang.javascript:
function commadot(that) {
if (that.value.indexOf(",") >= 0) {
that.value = that.value.replace(/\,/g,".");
}


function commadot(that) {
that.value = that.value.replace(/,/g,".");
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #4
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
McKirahan wrote on 12 dec 2004 in comp.lang.javascript:
function commadot(that) {
if (that.value.indexOf(",") >= 0) {
that.value = that.value.replace(/\,/g,".");
}


function commadot(that) {
that.value = that.value.replace(/,/g,".");
}
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)


<html>
<head>
<title>comadot.htm</title>
</head>
<body>
<form>
<input type="text" name="txt" onkeyup="this.value =
this.value.replace(/,/g,'.')">
</form>
</body>
</html>
Jul 23 '05 #5
McKirahan wrote on 12 dec 2004 in comp.lang.javascript:
<input type="text" name="txt" onkeyup="this.value =
this.value.replace(/,/g,'.')">


<input name="txt" value=""
onkeyup="this.value=this.value.replace(/,/,'.')">

if the value starts at empty,
there never can be more than one comma per keyup,
but for drag-drop and paste, where you were screwed anyway.

one would wish for:

onDragdrop should work only for a window,
and onPaste is nonexistend?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andreas | last post: by
4 posts views Thread by Unknown | last post: by
2 posts views Thread by Wilfried Mestdagh | last post: by
9 posts views Thread by Wayne | last post: by
6 posts views Thread by Tommy DN | last post: by
6 posts views Thread by ibiza | last post: by
19 posts views Thread by M. Posseth | last post: by
7 posts views Thread by JohnC | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.