I have some textboxes which are bind to decimal fields of a view model in cshtml file. Most of them have nine zeros after decimal. I want to show only 4 digits by default while editing them. However, I don't want to fix the length after decimal. Can anyone help me with this?
I suggest doing at c# controller or where you bind data to UI control like:
String.Format("{0:0.0000}", 123.456789012); // 123.4568
You can aslo do it in native javascript like :
var num = 123.456789012;
var n = num.toFixed(4); // 123.4568
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With