currency-formatting
How to format the currency in HTML5 with thymeleaf
You can use the #numbers utility object, which methods you can see here: http://www.thymeleaf.org/apidocs/thymeleaf/2.0.15/org/thymeleaf/expression/Numbers.html For example: <span th:inline=”text”>$ [[${#numbers.formatDecimal(abc.value, 0, ‘COMMA’, 2, ‘POINT’)}]]</span> Nevertheless, you can also do this without inlining (which is the thymeleaf recommended way): <td>$ <span th:text=”${#numbers.formatDecimal(abc.value, 0, ‘COMMA’, 2, ‘POINT’)}”>10.00</span></td>
Set value to currency in
Add step=”0.01″ to the <input type=”number” /> parameters: <input type=”number” min=”0.01″ step=”0.01″ max=”2500″ value=”25.67″ /> Demo: http://jsfiddle.net/uzbjve2u/ But the Dollar sign must stay outside the textbox… every non-numeric or separator charachter will be cropped automatically. Otherwise you could use a classic textbox, like described here.
html5 input for money/currency
Enabling Fractions/Cents/Decimals for Number Input To allow fractions on an number input, you need to specify the step attribute to any: <input type=”number” min=”1″ step=”any” /> This will specifically keep Chrome from displaying an error when a decimal/fractional currency is entered into the input. Mozilla, IE, etc… don’t error out if you forget to specify … Read more