Skip to main content
Nintex Community Menu Bar

How to format number with a comma

  • Sep 26, 2017 4:44 AM UTC
  • 3 replies
  • 147 views
  • Translate All

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
  • Sep 26, 2017 5:29 AM UTC

Hi John,

Check out this post:  

Cheers,

Chris

Translate

Forum|alt.badge.img+4
  • Author
  • Sep 26, 2017 6:44 AM UTC

hi Chris,

i did the suggested but its not working for me.

thanks

Translate

Forum|alt.badge.img+2

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);

Translate