By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,341 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

make input validating script accept comma?

P: n/a
I've found a useful script that only accepts numbers and a point, and 3
decimals, in an input. But here in denmark we normally use comma as
decimal delimiter in numbers, not the point (.) as in english-speaking
countries.

Can somebody help me making this javascript accept comma as delimiter
in the input? I'm thinking that the best solution is that the script
converts comma to a point, when the user input a comma.

http//sneleopard.dk/test.php

the included script: http://sneleopard.dk/filer/validate2.js

Jan 4 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In comp.lang.javascript message <11**********************@i80g2000cwc.go
oglegroups.com>, Thu, 4 Jan 2007 02:07:31, hygum <th*********@gmail.com>
posted:
>I've found a useful script that only accepts numbers and a point, and 3
decimals, in an input. But here in denmark we normally use comma as
decimal delimiter in numbers, not the point (.) as in english-speaking
countries.

Can somebody help me making this javascript accept comma as delimiter
in the input? I'm thinking that the best solution is that the script
converts comma to a point, when the user input a comma.
See <URL:http://www.merlyn.demon.co.uk/js-maths.htm#DPV>.

In practice, to get a Number from a control Ctrl,

function DaneRead(Ctrl) { return +Ctrl.value.replace(/,/, '.') }

It's a good idea to read the newsgroup and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Jan 4 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.