how to convert string into parsefloat format?
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?