1
0
-1

Hello Expert, 

I have create a textfield as figure below:

And I also create a HTML to add thousand seperator:

<script type="text/javascript">
$(document).ready(function() {
var textbox = '#amount';
var hidden = '#ThousandSeperator_num';
$(textbox).keyup(function () {
var num = $(textbox).val();
var comma = /,/g;
num = num.replace(comma,'');
$(hidden).val(num);
var numCommas = addCommas(num);
$(textbox).val(numCommas);
});
});

function addCommas(nStr) {
nStr += '';
var comma = /,/g;
nStr = nStr.replace(comma,'');
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;
}
</script>

But in the end "the result is return String value. Not a  number.

How to fix the code above to convert String value into ParseFloat?

 

 

 

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Thang

      There is a Currency Form Field element plugin you can download and use from Joget Marketplace. You can configure the thousand separator plus many other parameters for this input field.

      Do take the time to explore and use all the free plugins and apps from Joget Marketplace in your application (smile).

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hello Matthew, 

        Thanks for the answer. It work as I expected. However, how to remove the last two digits?

          CommentAdd your comment...