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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to remove $ and , and any white space from a text field

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
I need to remove the $ and , and any white space from a text field. Anyone got a quick and easy fix? Thanks a million.

Jewel

When faced with a decision, always ask, 'Which would be the most fun?'
 
This isn't a full answer. You want something to trim whitespace to remove it from the beginning & end. What I have posted only converts doubles into singles :(

You could use substring but I suspect someone else will post a cleaner solution.

content = forms[0].textarea.value;
multi = new RegExp(' ', 'gi');
single = ' ';
content = content.replace(multi,single);
forms[0].textarea.value = content;

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
This is a perfect place for a regular expression and the replace method:
Code:
var myRE = /[\$\s]/g;
theString = theString.replace(myRE,"");


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top