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
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
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 -
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
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.