I've been trying to format number to currency using JavaScript, but every regex expression that I try doesn't work.
I have a paragraph:
<p class="text-primary" id="totalPaymentAllocatedLabel">Allocated Amount: $1,050.52</p>
Then I enter in a "number" input the value: 1150
Using JQuery, I try to edit the paragraph:
$("#totalPaymentAllocatedLabel").val(newValue.toFixed(2).replace(/(\d)(?=(\d{3})+$)/g, ""));
Then, it displays Allocated Amount: $1150.00 I would like $1,150.00
What am I doing wrong?
Thanks