How to do Trim operation to remove space character in a text field in JavaScript?
From stackoverflow
-
A total dupe of this question:
http://stackoverflow.com/questions/196925/what-is-the-best-way-to-trim-in-javascript
Unless you didn't actually mean trim of course and in fact wanted all the spaces replaced ? In which case you just want:
var myString = "foo bar ddd"; myString = myString.replace(/ /g, "");
-
in case you did mean Trim:
x.replace(/^\s*|\s*$/g,'');
0 comments:
Post a Comment