formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.86k stars 1.05k forks source link

Number component not working for long values #5445

Open gyanendrasinghpanwar opened 8 months ago

gyanendrasinghpanwar commented 8 months ago

I presume this due to below function in Number.js where we have used parseInt.

parseNumber(value) { // Remove delimiters and convert decimal separator to dot. value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');

if (this.component.validate && this.component.validate.integer) {
  return parseInt(value, 10);
}
else {
  return parseFloat(value);
}

}

travist commented 7 months ago

I believe this has more to do with JavaScript limitations rather than this library limitations. Do you have an example number that causes failures?

gyanendrasinghpanwar commented 7 months ago

I believe this has more to do with JavaScript limitations rather than this library limitations. Do you have an example number that causes failures?

"Indeed, this is more with JavaScript limitation. Currently, the number component is working accurately with up to 15 digits; after that, there is data loss due to parseFloat."

Do we have any plans to provide BigInt support in the number component or to offer number validation in the textfield component so that it can be used from there?

Let me know if need any Pull request.

youcefelwaer commented 4 months ago

hello i used this work around on the calculated Value logic const inputValue=data['test']; if ((inputValue.length>15)) { value=parseFloat(inputValue.replace(".","").substring(0,15)); }