Frequently asked questions Custom Code

How do I add a digit group separator?

How do I add a digit group separator?

Examples below require knowledge of Javascript and CSS. Tilda Customer Support does not assist in code-related questions.

To add a digit group separator to a calculator form, you need to add a T123 block from the “Other” category, use this:

<script>
function tcalc__changeVal(a, e, t) {
e.html(t.toLocaleString("ru-RU"));
a.find(".t-calc__hiddeninput").val(t)
}
</script>

To add a digit group separator in the products price (for example, in an ST200 block), use this:

<script>
$(document).ready(function() {
$.each($("div.js-product-price"), function() {
var thisClass = $(this).attr("class");
var thisPrice = parseInt($(this).text()).toLocaleString("ru-RU");
$(this).css("display", "none");
$(this).before("<div class='" + thisClass + "'>" + thisPrice + "</div>");
});
});
</script>

ru-RU — to add a space separator;

en-US — to add a comma separator

Was this answer helpful?
Yes
0
No
0
Views: 16542