2

So I have this piece of code:

var thisValue = $("input[id*=ID222]").val(); 
thisValue = thisValue.replace(',','');

Basically I want to remove all commas in this input element for taking it up for further processing. The above code works when there is only one comma in the field, but doesn't work for multiple commas. Is there another way? I tried replaceAll, and it didn't work.

2

1 Answer 1

7

You have to do a global replace using a regular expression. You can't do this by passing a string to replace:

thisValue = thisValue.replace(/,/g,'');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.