469,282 Members | 2,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Nueric pad keys

Hello to everyone,
do you know if it's possible (through a javascript in a HTML page) to
intercept when the user press the "." (period) key of the numeric pad and
replace it with a comma (italian "decimal point" is "comma" and I'm
developing an intranet apllication for an italian customer)

Thanks,
Davide
Jul 20 '05 #1
17 3879
Hello, Davide!

Here is the code:
-----------------------
<html>
<head>
<script language="javascript">
function CheckStr()
{
var f = document.myform.myedit.value;
re=RegExp('[.]','gi');
f=f.replace(re,',');
document.myform.myedit.value=f;
}

</script>
<body>
<form action="" name="myform">
<input type="text" name="myedit" onkeyup="CheckStr();">
<input type="submit">
</form>
</body>
</html>
-----------------

Did it help you?
Kindest Regards,
Olexiy Merenkov
http://www.merenkov.com/olexiy

Hello to everyone,
do you know if it's possible (through a javascript in a HTML page) to
intercept when the user press the "." (period) key of the numeric pad and
replace it with a comma (italian "decimal point" is "comma" and I'm
developing an intranet apllication for an italian customer)

Thanks,
Davide

Jul 20 '05 #2
Thank you Olexiy,
it works fine, but if I use the "period" key that is not on the numeric pad,
the script write a comma.
Do you know if it's possible to write a comma ONLY by pressing the period
key on the numeric pad?

(I can use Microsoft Internet Explorer specific features, because this is an
intranet application used only with Internet Explorer)

Thanks,
Davide.


Jul 20 '05 #3

Sorry but I don't understand what is this 'period key'. If you mean comma
that is up
the spacebar, it work ok for me...
Do you know if it's possible to write a comma ONLY by pressing the period
key on the numeric pad?


This code replaces commas after pressing the key so if you know undesired
symbol code
you can easily replace it by point '.' or with empty space ''

-
Kindest Regards,
Olexiy Merenkov
http://www.merenkov.com/olexiy

Jul 20 '05 #4

Sorry but I don't understand what is this 'period key'. If you mean comma
that is up
the spacebar, it work ok for me...
Do you know if it's possible to write a comma ONLY by pressing the period
key on the numeric pad?


This code replaces commas after pressing the key so if you know undesired
symbol code
you can easily replace it by point '.' or with empty space ''

-
Kindest Regards,
Olexiy Merenkov
http://www.merenkov.com/olexiy

Jul 20 '05 #5
Olexiy Merenkov wrote on 10 aug 2003 in comp.lang.javascript:
Sorry but I don't understand what is this 'period key'. If you mean comma


In the US they say [for unknown reasons] "period" for "point",
both meaning the "." character, Olexiy.

So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6
Olexiy Merenkov wrote on 10 aug 2003 in comp.lang.javascript:
Sorry but I don't understand what is this 'period key'. If you mean comma


In the US they say [for unknown reasons] "period" for "point",
both meaning the "." character, Olexiy.

So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #7
>
So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.


Yes, also on an italian keyboard.
But in Italy the "decimal point symbol" is not a point (".") but a comma
(",").
So, if in the USA people wrotes 1,000.50 (one thousand and 50 pennies), in
Italy we usually wrote 1.000,50.
Some programs (like italian version of Microsoft Access for example) write a
comma when you press the "decimal point" of the numeric pad, but Internet
Explorer doesn't do this (and I want to do this in my web application).

Davide.
Jul 20 '05 #8
>
So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.


Yes, also on an italian keyboard.
But in Italy the "decimal point symbol" is not a point (".") but a comma
(",").
So, if in the USA people wrotes 1,000.50 (one thousand and 50 pennies), in
Italy we usually wrote 1.000,50.
Some programs (like italian version of Microsoft Access for example) write a
comma when you press the "decimal point" of the numeric pad, but Internet
Explorer doesn't do this (and I want to do this in my web application).

Davide.
Jul 20 '05 #9
Davide R. wrote on 11 aug 2003 in comp.lang.javascript:
So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.
Yes, also on an italian keyboard.
But in Italy the "decimal point symbol" is not a point (".") but a
comma (",").


Then it is not a "decimal point" but a "decimal comma" ;-)
So, if in the USA people wrotes 1,000.50 (one thousand and 50
pennies), in Italy we usually wrote 1.000,50.
Also here in the Netherlands
Some programs (like italian version of Microsoft Access for example)
write a comma when you press the "decimal point" of the numeric pad,
Terrible.
but Internet Explorer doesn't do this (and I want to do this in my web
application).


<input
onkeydown="if(event.keyCode==110){this.value+=','; return false}"
style="font-size:30pt;">

This only works if the cursor is on the far right !!!

=====================

<input
onkeydown="this.value=this.value.replace(/\./g,',')"
onblur="this.value=this.value.replace(/\./g,',')"
style="font-size:30pt;">

This works for all points, but on the next key or blur.

======================

Please warn your users beforehand !!!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #10
Davide R. wrote on 11 aug 2003 in comp.lang.javascript:
So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.
Yes, also on an italian keyboard.
But in Italy the "decimal point symbol" is not a point (".") but a
comma (",").


Then it is not a "decimal point" but a "decimal comma" ;-)
So, if in the USA people wrotes 1,000.50 (one thousand and 50
pennies), in Italy we usually wrote 1.000,50.
Also here in the Netherlands
Some programs (like italian version of Microsoft Access for example)
write a comma when you press the "decimal point" of the numeric pad,
Terrible.
but Internet Explorer doesn't do this (and I want to do this in my web
application).


<input
onkeydown="if(event.keyCode==110){this.value+=','; return false}"
style="font-size:30pt;">

This only works if the cursor is on the far right !!!

=====================

<input
onkeydown="this.value=this.value.replace(/\./g,',')"
onblur="this.value=this.value.replace(/\./g,',')"
style="font-size:30pt;">

This works for all points, but on the next key or blur.

======================

Please warn your users beforehand !!!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #11
>
<input
onkeydown="if(event.keyCode==110){this.value+=','; return false}"
style="font-size:30pt;">

This only works if the cursor is on the far right !!!


Great! It works
Any Idea when the cursor is not on the far right?

Davide.
Jul 20 '05 #12
>
<input
onkeydown="if(event.keyCode==110){this.value+=','; return false}"
style="font-size:30pt;">

This only works if the cursor is on the far right !!!


Great! It works
Any Idea when the cursor is not on the far right?

Davide.
Jul 20 '05 #13
"Davide R." <aa*@bb.com> wrote in message
news:bh**********@newsreader.mailgate.org...

So, if in the USA people wrotes 1,000.50 (one thousand and 50 pennies), in
Italy we usually wrote 1.000,50.


Actually, USA: 1,000.50 (one thousand and 50 pennies)
Italy: 1.000.000,50 (one million lira and a half)

Or roughly that much. I didn't check the latest conversion rate. ;-)

--
Steve

Jul 20 '05 #14
Steven Dilley wrote on 11 aug 2003 in comp.lang.javascript:
"Davide R." <aa*@bb.com> wrote in message
news:bh**********@newsreader.mailgate.org...
>

So, if in the USA people wrotes 1,000.50 (one thousand and 50
pennies), in Italy we usually wrote 1.000,50.


Actually, USA: 1,000.50 (one thousand and 50 pennies)
Italy: 1.000.000,50 (one million lira and a half)

Or roughly that much. I didn't check the latest conversion rate. ;-)


You heavily miss the point [or the comma], Steve:

Actually:

USA: 1,000.50

Italy: 1.128,36 (rate of 2 minutes ago)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #15
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Davide R. wrote on 11 aug 2003 in comp.lang.javascript:
So the "Period key" on the numeric pad is
between the "0" and the "enter" on a US keyboard.


Yes, also on an italian keyboard.
But in Italy the "decimal point symbol" is not a point (".") but a
comma (",").


Then it is not a "decimal point" but a "decimal comma" ;-)


What is on the key? Does the keycap have a '.' or a ','?
Wouldn't a key with a point/period/dot which actually functions
as a comma would be confusing? If there is a comma on the key,
can't the keyboard (that is the kbd driver) be configured to send
a comma? Can't this be solved through the 'Locales' or 'Regional
Settings'?

Apologies for asking these questions, but living in the same country
as microsoft has some advantages: I haven't had to struggle through
any of this. I am just curious why a problem that is so widespread,
and that has been around for so long, hasn't been solved already.

-- Steve

Jul 20 '05 #16
Steven Dilley wrote on 11 aug 2003 in comp.lang.javascript:
Apologies for asking these questions, but living in the same country
as microsoft has some advantages: I haven't had to struggle through
any of this. I am just curious why a problem that is so widespread,
and that has been around for so long, hasn't been solved already.


We pity you there in the States, struggling with outdated idea's of square
inches that have to be converted to square feet or square miles, of filling
your car with quarters that are not even the same as those in England,
coding your dates month-day-year and not in a logical dmy or ymd form, like
we do [never missing our first date], and of trying to convince us [the
world] that 12 am and 12 pm are logically and not confusingly what they
should be [we stil don't know]. NASA even proved these unit conversion
mistakes by [thankfully?] crashing a spaceprobe on Mars.

Be assured, the grey decimal point key is a minor nusance.

Anyway it is very refreshing that you care, thank you very much Steven.

;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-} ;-}

PS: forgot to include Farenheit conversion to Kelvin and back. Farenheit
was an Amsterdammer, Lord Kelvin quite British.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #17
JRS: In article <3f******@10.10.0.241>, seen in
news:comp.lang.javascript, Steven Dilley <steven.dilley.at.compuware.com
@?.?> posted at Mon, 11 Aug 2003 10:58:30 :-
"Davide R." <aa*@bb.com> wrote in message
news:bh**********@newsreader.mailgate.org...
>

So, if in the USA people wrotes 1,000.50 (one thousand and 50 pennies), in
Italy we usually wrote 1.000,50.


Actually, USA: 1,000.50 (one thousand and 50 pennies)
Italy: 1.000.000,50 (one million lira and a half)


It's always instructive to see how /au fait/ some people are with
economic developments overseas. The Italian Lire was abandoned a year
and a half ago, at a conversion rate of 1936.27 lira.

To avoid ambiguity, the dot and comma should be referred to as the
decimal and thousands separators, in whichever order is applicable.

--
John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
Dates - miscdate.htm Year 2000 - date2000.htm Critical Dates - critdate.htm
Euro computing - eurocash.htm UK Y2k mini-FAQ: y2k_mfaq.txt Don't Mail News
Jul 20 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Blair Hall | last post: by
9 posts views Thread by Etienne Charland | last post: by
4 posts views Thread by pixel | last post: by
reply views Thread by Menlalen | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.