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