Can't add commas to numbers

I can’t add commas to numbers in the CMS.

1 Like

That is correct. You can’t add text to a numeric field.

If you need commas, you can use a text field.

See also How to add 3 digit comma separator - #2 by cyberdave

I updated the fields to text fields. It is working now. Ideally that format option in the binding itself would allow for multiple string representations similar to the date formatting that happens on date bindings.

1 Like

Can you guide me? I have used multiple integrations.
So basically that Digit balance is being assigned from airtable and I did it by connecting zapier with airtable. I am not getting how to do that.
THANKS

Hey Mahr, your question isn’t clear on what you’re trying to do, where you’re finding problems, or what you’ve tried.

But if it’s related to formatting numbers, the easiest way is probably to format the number in the presentation layer and not in the data itself. Here’s how I approach it;

1 Like

For anyone coming across this in the future, drop this code in your individual page settings header. Then, add an ID of “comma” to the text block that is pulling in the number field from your CMS.

<script>
window.addEventListener('load', function() {
  addCommas();
});

function addCommas() {
  var numBlocks = document.querySelectorAll("#comma");
  for (var i = 0; i < numBlocks.length; i++) {
    var num = parseFloat(numBlocks[i].textContent.replace(/,/g, ''));
    if (!isNaN(num)) {
      numBlocks[i].textContent = num.toLocaleString();
    }
  }
}
</script>
4 Likes

Thanks for this!
Note for anyone using this fix: you will only be able to view the commas on the published site

1 Like

@myonke You sir, are a scholar and a gentleman! Thanks so much!
It works!