Hi Experts !
looking for solution to block some sign for Users in form.
I have a field "DataCardValue" which is for "Amount" input.
End users are adding "-" and "+" signs all the time, which messing up the report in Power BI, where we visualize data.
Is there any way to restrict that and let them only input numbers?
No special signs, no letters, just pure numbers (decimals).
I have no idea how to do that, just created a prompt which is "visible" when user input "-" or "+"sing.
But it does not work for end users, they still enter those signs, so I want to block that permanently for that one field alone.
Would be grateful for help/ advice on that 🙂
Hi @Patryk92,
Try this then:
Set the Default property of the TextInput to:
Coalesce(
locNumber,
Parent.Default
)
The insert a slider control with the below properties:
Visible = false
Default = Len(DataCardValue9.Text)
OnChange = UpdateContext({locNumber:With({_Value:Trunc(DataCardValue9.Text)},If(_Value<0,_Value*-1,_Value))});
Reset(TextInput5);
What this does, is every time something is typed in the DataCardValue, the text is taken and manipulated:
Value removes and "+",
Trunc removes any ".",
The If statement removes any "-"
This is then saved in a local variable which is will be displayed be default in the DataCardValue because it is reset.
The only thing to take into consideration is to set the local variable back to blank when the user submits the form (in the OnSuccess property of the form) or when the user navigates away from the screen. This is important because otherwise the DataCardValue may display a wrong value.
Hi !
Thanks for answer on my query 🙂
I tested what you suggested
IsNumeric(DataCardValue9.Text)
just for the "warning label", and seems that this formula is evaluating "-1234" and "1234" and "+1234" as "true", so it does not work as expected 😞
what is needed is to evaluate "-1234" and "+1234" as false, and only "1234" as true
in this field characters (letters) are blocked anyway by the Property > Format = Number, but this does not block "-" and "+" from entering to that field
Maybe there is a way to "clear" the field if it contains "-" or "+" sign or any other way to achieve that?
Not sure about that... hmm
Hi @Patryk92 ,
You can use this condition to validate if the contents are numeric:
IsNumeric(DataCardValue9.Text)
This condition can be used to, for instance, block the user from submitting the form and show a warning.
WarrenBelz
198
Most Valuable Professional
MS.Ragavendar
108
stampcoin
80