Re: How to format textbox value before sum?
- From: Randy Webb <HikksNotAtHome@xxxxxxx>
- Date: Tue, 14 Mar 2006 08:45:54 -0500
staeri@xxxxxxxxx said the following on 3/14/2006 7:55 AM:
I'm grateful for the answers but they none of them are working on my
system. One textbox contains for example the value "2 100". This should
be treated as "2100" but is treated like "NaN".
Maybe it's easier to say that space, dot or comma should be eliminated.
<input onchange="
this.value=this.value.replace(/\./g,'').replace(/\,/g,'').replace(/\ /g, '');"
Will remove any commas, any dots and any spaces from the input. Test it :)
And if the user by mistake writes anything else than numbers it should
be treated like "0" so that they always get a correct sum.
So, if I type in "Randy Webb" instead of 123, it should deduce that I meant 0? Test it for all digits after removing spaces commas and periods. Then, if it contains non-digits you tell the user they have incorrect input.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.
- References:
- How to format textbox value before sum?
- From: staeri
- Re: How to format textbox value before sum?
- From: Randy Webb
- Re: How to format textbox value before sum?
- From: Dr John Stockton
- Re: How to format textbox value before sum?
- From: Thomas 'PointedEars' Lahn
- Re: How to format textbox value before sum?
- From: staeri
- How to format textbox value before sum?
- Prev by Date: Re: Help, I am new to Javascript
- Next by Date: Re: How to format textbox value before sum?
- 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