Re: How to format textbox value before sum?
- From: Dr John Stockton <jrs@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Mar 2006 23:41:12 +0000
JRS: In article <B6adnXAmDdmFs5DZRVn-vw@xxxxxxxxxxx>, dated Tue, 7 Mar
2006 01:54:30 remote, seen in news:comp.lang.javascript, Randy Webb
<HikksNotAtHome@xxxxxxx> posted :
var n = +f[i].value.replace(' ','').replace('.','').replace(',','');
Will remove any spaces, commas or periods (dot). Makes me wonder what
happens if it has a decimal part to it though......
In a function UpdateBudget, one should not expect decimal parts. "A
billion here, a billion there - it soon adds up to real money" (approx).
Assuming your answer to have only the obvious answer-affecting error,
var n = +f[i].value.replace(/[\. ,]/g, "")
in which, in my system, the \ is not actually needed.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.
- Follow-Ups:
- Re: How to format textbox value before sum?
- From: Thomas 'PointedEars' Lahn
- Re: How to format textbox value before sum?
- References:
- How to format textbox value before sum?
- From: staeri
- Re: How to format textbox value before sum?
- From: Randy Webb
- How to format textbox value before sum?
- Prev by Date: Re: Date Field in a <FORM>
- Next by Date: Re: Browser text size setting
- Previous by thread: Re: How to format textbox value before sum?
- Next by thread: Re: How to format textbox value before sum?
- Index(es):
Relevant Pages
|
Loading