-3

In HTML, TextBox values need to fix with fixed decimal point, that is only for displaying. But inside that TextBox need to keep the original value with all decimal points.

Example in excel we have eg screenshot. Cell formatted with two decimal points. But that have original value inside without any data truncation(showing formula bar). Similar operation is possible with HTML TextBox?

1 Answers1

0

It can be done in 2 ways.

  1. Make a variable to keep the old value and add the truncated value in another variable which you can use to display.

  2. Make a function in javascript that will simply return the truncated value to the view.

In either cases, you ll have to check if there is any change in the value that you put in the textbox then keep the newer value or else keep the old value with more number of decimal points. This is a simple Javascript approach.

There is a semi-Css approach here on this link. Formatting numbers (decimal places, thousands separators, etc) with CSS

Hope this helps. And please let me know if i misinterpreted your question

Community
  • 1
  • 1
Tirthraj Barot
  • 2,671
  • 2
  • 17
  • 33