Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove a character from a string

Status
Not open for further replies.

rkoya

IS-IT--Management
Joined
Jul 12, 2004
Messages
57
Location
GB
Hello,

I am having trouble removing a ',' from a string. Basically I have prices such as 225.41, 356.99 etc.. which I convert to an integer using parseFloat.When it gets to 1,000 because of the comma between the 1 and the zeroes it doesn't recognise it as an integer using parseFloat. Is there a way to remove the comma from the string and just recognise it as 1000 rather than 1,000. Any help would be appreciated.

Thanks
 
[tt]var x="1,225.41";
var y=x.replace(/,/g,''); //now without comma[/tt]
 
Also, know your users. Comma may be separating dollars from cents as well for other part of the world.
 
Thanks for your help, worked a treat. It is in pound sterling so hopefully shouldn't have a problem. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top