Connecting Tech Pros Worldwide Forums | Help | Site Map

replace function script not working

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: 3 Weeks Ago
I'll probably be laughed at for this attempt of coding, but all I am trying to do is read an input field, remove the "$" and write the new value in a different input field.

Expand|Select|Wrap|Line Numbers
  1. function convert_action (form){
  2. var input1=form.input_field1.value;
  3. var clean=input1.replace(/$/, '');
  4. form.input_field2.value = clean;
  5. }
Looks simple, and thought this would work, it kindof does, it just does not strip out the dollar sign... Help would be appreciated...greatly...

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,660
#2: 3 Weeks Ago

re: replace function script not working


the dollar sign is a special character in RegExp. you need to escape it.
Reply