I have a text field "City Name" on my Power Apps Canvas App. How can I restrict the text field only to Alphabet and Spaces. It shouldn't allow any special characters or numbers.
Hi,
In my case I have a number field which allows + and - symbol to enter in the field and gives a error message " The value - cannot be converted to a number". For other special characters it's not allowing to enter.
Any help would be greatly appreciated.
Hi @RameshMukka ,
Do you want to restrict a textinput that user could only enter Alphabet and Spaces?
I'm afraid it's not supported to directly restrict a textinput to not allow characters or numbers.
For a textinput, you could only restrict whether you enter number or text. Text includes Alphabet, Spaces and character.
As an alternative solution, I suggest you add a justification when updating.
If the data in textinput includes characters or numbers, you could not update data and get a warning.
If the data in textinput only includes Alphabet and Spaces, you could update successfully.
You just need to set the submit button's OnSelect like this:
If(IsMatch(TextInput1.Text, "[a-zA-Z\s]+"),
//[a-zA-Z\s] represents Alphabet and Spaces, + represnets one or more
SubmitForm(formname),
Notify("please do not enter character or number in this field!",NotificationType.Warning)
)
Best regards,
@RameshMukka
This is not possible in a Power Apps text field. You can restrict input to numbers only but not letters.
As a workaround you can check whether only letters and spaces were input into the text box using this code
IsMatch(TextInput1.Text, "[a-zA-Z\s]+")
More details on the ISMATCH function here:
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-ismatch
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
There is no easy way to limit the characters that a user enters into a text field. However, you could easily setup a label with an error message and have that message display if the user types a non-allowed character by testing the input with an IsMatch() regex expression.