Skip to main content
Nintex Community Menu Bar
Solved

How to add thousand separators to integer fields in a repeating section

  • November 29, 2016
  • 4 replies
  • 206 views
  • Translate

Hi,

 

I have a form with a repeating section where there are several fields with the integer data type. I want to use thousand separators in those fields, but have not figured out how. Is it possible?

 

Thanks!

Lisa

Best answer by amolvaidya

for all integer fields assign a css class (this is just for selection sake, you need not actually have that css class). lets say our class is "numbers"

include an external js file to your nintex form or add below code to custom javascript for the form

//Function to do the comma magic

function commaSeparateNumber(val)
{
  if (!val)
  {
    return 0;
  }
  while (/(d+)(d{3})/.test(val.toString()))

  {
      val = val.toString().replace(/(d+)(d{3})/, '$1'+','+'$2');
  }

  return val;
}

//pick each ".numbers" element and do the comma thing

function doNumberFormat()
{

  //Handles single line text boxes in view mode
  $('.numbers .ms-rtestate-field').each(
  function(index,element){
    $(this).html(commaSeparateNumber($(this).html()));
  });

  //Handles calculated value in view mode
  $('.numbers .nf-calculation-control').each(
  function(index,element){
    $(this).html(commaSeparateNumber($(this).html()));
  });
}

//Call the formatter function after loading the page

setTimeout(doNumberFormat, 5000);

explanation for above code

commaSeparateNumber - will format text with thousand seperator

doNumberFormat - will iterate through each control where css class is set to "numbers". Within that set it will then find controls with css class "ms-rtestate-field". It will then pass the html contents of current control to the commaSeparateNumber function to get back formatted text and replace html.

same for "nf-calculation-control"

 

the last line setTimeout will call the format function after 5 seconds of page load. Adjust this time according to your page.

Edit (Philipp Lucas): See this post for corrected code -  

View original
Did this topic help you find an answer to your question?

Forum|alt.badge.img+5

for all integer fields assign a css class (this is just for selection sake, you need not actually have that css class). lets say our class is "numbers"

include an external js file to your nintex form or add below code to custom javascript for the form

//Function to do the comma magic

function commaSeparateNumber(val)
{
  if (!val)
  {
    return 0;
  }
  while (/(d+)(d{3})/.test(val.toString()))

  {
      val = val.toString().replace(/(d+)(d{3})/, '$1'+','+'$2');
  }

  return val;
}

//pick each ".numbers" element and do the comma thing

function doNumberFormat()
{

  //Handles single line text boxes in view mode
  $('.numbers .ms-rtestate-field').each(
  function(index,element){
    $(this).html(commaSeparateNumber($(this).html()));
  });

  //Handles calculated value in view mode
  $('.numbers .nf-calculation-control').each(
  function(index,element){
    $(this).html(commaSeparateNumber($(this).html()));
  });
}

//Call the formatter function after loading the page

setTimeout(doNumberFormat, 5000);

explanation for above code

commaSeparateNumber - will format text with thousand seperator

doNumberFormat - will iterate through each control where css class is set to "numbers". Within that set it will then find controls with css class "ms-rtestate-field". It will then pass the html contents of current control to the commaSeparateNumber function to get back formatted text and replace html.

same for "nf-calculation-control"

 

the last line setTimeout will call the format function after 5 seconds of page load. Adjust this time according to your page.

Edit (Philipp Lucas): See this post for corrected code -  

Translate

TomaszPoszytek
Forum|alt.badge.img+17

Lisa Morgan‌ are you using Nintex Forms or Infopath? Where do you want to display the number formatted properly? In the form itself or in the list item display form?

I guess in Nintex Forms you can set field formatting the same way as in Infopath - so you can set data type to "decimal" (or number) and then in formatting set a proper mask when a value is displayed:

Regards,

Tomasz

Translate

TomaszPoszytek
Forum|alt.badge.img+17

Hi!

Have you found a solution for your question? Or do you find any from the answers as "Correct" so that you can mark it accordingly?

Best regards,

Tomasz

Translate

Forum|alt.badge.img+3
  • Rookie
  • February 23, 2021
Is this available on Nintex 2013 as well? Cannot find that option in TextBox.
Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings