How to format number with a comma

  • 26 September 2017
  • 3 replies
  • 51 views

Badge +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

Userlevel 6
Badge +12

Hi John,

Check out this post:  

Cheers,

Chris

Badge +4

hi Chris,

i did the suggested but its not working for me.

thanks

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

Reply