Skip to main content
Nintex Community Menu Bar

How to format number with a comma

  • September 26, 2017
  • 3 replies
  • 139 views

Forum|alt.badge.img+4

hi all,

how can i format number with a comma to my input control (single line textbox) in nintex form ?

my input control is connected to a numeric columm.

thanks

3 replies

Chris_Ben
Nintex Employee
Forum|alt.badge.img+14
  • Nintex Employee
  • September 26, 2017

Hi John,

Check out this post:  

Cheers,

Chris


Forum|alt.badge.img+4
  • Author
  • September 26, 2017

hi Chris,

i did the suggested but its not working for me.

thanks


Forum|alt.badge.img+2
  • September 28, 2017

A Nintex text box (and also the TekDog Input Mask) when bound to a Numeric column both have the same behavior of removing the commas displayed by SharePoint's view. The format string setting in Nintex doesn't seem to work for me either, or I'm not sure what the intended behavior is.

However, a function to format a number with commas is available here:

"Number Format in JavaScript"

http://raovishal.blogspot.com/2012/01/number-format-in-javascript.html

Using the addCommas function and setting the JavaScript client ID variable name in Nintex to varNumericOneClientId, you could force the comma format with the following code in the form settings:

function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(d+)(d{3})/;
    while (rgx.test(x1)) {
      x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
return x1 + x2;
}

var commaFormat = addCommas(NWF$('#' + varNumericOneClientId).val());

NWF$('#' + varNumericOneClientId).val(commaFormat);