Numbers with fixed decimal places
Good day,
Since one of last versions of SRF rich forms is always returning numbers with two decimals.
How can I return numbers without decimals?
There are informations like EmpID's which needs to be shown like "10" and not like "10,00"
Thank you
-
Hello Senad Omicevic
I prepared solution for you.
On your form where you want have numbers without decimal place please create Form Load Action
with type Execute Script and add this script:
var oldLocaleFormatFunc = Number.prototype.localeFormat;
var defaultNumberDecimalDigitsValue = Sys.CultureInfo.CurrentCulture.numberFormat.NumberDecimalDigits;
Number.prototype.localeFormat = function(){
var numberValue = this;
var hasNumberValueDecimalPart = numberValue % 1 != 0;
if(!hasNumberValueDecimalPart){
Sys.CultureInfo.CurrentCulture.numberFormat.NumberDecimalDigits = 0;
var localizedValue = oldLocaleFormatFunc.apply(numberValue,arguments);
Sys.CultureInfo.CurrentCulture.numberFormat.NumberDecimalDigits = defaultNumberDecimalDigitsValue;
return localizedValue;
}
return oldLocaleFormatFunc.apply(numberValue,arguments);
}In runtime if you will insert number with decimal part like 5.6 or 5.653 it'll be rounded to 5.60 or 5.65 and according to your regional settings. But if you will insert number without decimals like 6 it will not be rounded.
Kind Regards
Andriy Berezovsky0 -
Hi Andriy,
Thank you, this is working great.
0
Please sign in to leave a comment.
Comments
2 comments