HeX
{ USER }
posts: 8
last: 11-Aug-2008
TITLE: Remove special characters from a string
DESCRIPTION: Remove special characters from a string
Submitted: 11-Aug-2008 23:07:30 ( 14w 1d 18h ago ) Language: JavaScript (*.js *.jscript *.jsb)
Views: 187 Lines of Code: 16 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 3.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 
   Date: 11-08-2008
   Filename: 
   Description: 
   History: 
*/

function clearText() {
     document.formname.fieldname.value=filterNum(document.formname.fieldname.value)

     function filterNum(str) {
          re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
          // remove special characters like "$" and "," etc...
          return str.replace(re, "");
     }
}