How to restrict user to enter only 2 digit value after decimal point?

0
Hi, I have one textbox field which contains a decimal value but I want restrictions on the textbox field. when the user enters 12.22 it should be fine but if the user wants to enter 12.234 in this condition textbox should not allow to enter 3rd digit. so how to acheive these scenario?  
asked
1 answers
0

Hi Madhura,

There are a number of ways you can approach this.

 

You can set a data validation rule in the domain model, you could use a Regular Expression to check that the input only has two digits after the decimal point.

https://docs.mendix.com/howto/data-models/setting-up-data-validation/ 

 

You can create your own validation logic in a microflow that is triggered either on the page save action or on navigating out of the text box, use the On leave / On Enter key press event.  Use an if condition with an expression like

isMatch(toString($Input/Number), '^\s*(?=.*[1-9])\d*(?:\.\d{1,2})?\s*$')

answered