replace function script not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nucleusnet
    New Member
    • Oct 2009
    • 1

    replace function script not working

    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.

    Code:
    function convert_action (form){
    var input1=form.input_field1.value;
    var clean=input1.replace(/$/, '');
    form.input_field2.value = clean;
    }
    Looks simple, and thought this would work, it kindof does, it just does not strip out the dollar sign... Help would be appreciated...g reatly...
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

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

    Comment

    Working...