how to convert string into parsefloat format?

Confluence User - 19 Aug, 2016

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?

 

 

 

forms;user;userviews

2


20 Aug, 2016
confluenceUser
confluenceUser

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

22 Aug, 2016
confluenceUser
confluenceUser

Hello Matthew, 

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

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print