on 2025 Feb 03 4:07 PM
Hello,
I have created a Data Entity with a field where the data type is set to Number. Then, I created a Page Variable with the data type also set to Number.
I added an Input Box and bound it to the Page Variable. The data entered in the Input Box is supposed to be stored in the data entity field, which only accepts numeric values.
Even though the data type is set to Number in both the Page Variable and the Data Entity field, the Input Box still allows the user to enter and save non-numeric values.
How can I restrict the Input Box to accept only numeric values and prevent the user from entering non-numeric characters?
Request clarification before answering.
The best I can find is to use the "Set Component Properties" flow function with the onChange event of the input field.
You set the component's value field with the following formula:
IF(MATCHES_REGEX(SUBSTRING(pageVars.input,-1), "[0-9]"),pageVars.input,SUBSTRING(pageVars.input,0,-1))
It checks for a digit at the end and if not it removes the character. The "input" variable is a text field -- you'll have to convert it when you want to use as a number.
I still get a small flash of the character and its removal, but it's pretty quick.
Our old friend @kleventcov (Kirill 😺) has a wonderful blog on validation schemes which are worth checking out. It includes validation on submit though not on individual field input: https://community.sap.com/t5/technology-blogs-by-sap/moderating-user-input-in-sap-build-apps/ba-p/13...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.