How do I get my UMG text box to not allow mature language, numbers, and special characters?

Hello! I’m new to Blueprint/UE and I wanted to make a text box where the player types their name, but I don’t want to allow them to be able to type mature language/curse words, numbers, or special characters. And if it’s not too much trouble, I also need help on limiting the number of characters the player is able to type and not letting them proceed to the game until they have typed a name.

Thanks in advance! :slight_smile:

You nedd to create a Variable in your UMG, make it a String and an Array.

Fill it with a List of your forbidden Text Content.

When selecting your EditableText Widget, create an “OnTextChanged” Event.

Two ways now:
Check your EditableText against each forbidden word by using a foreach loop of the Array and a (String)Contains Node. If one exists, use String Replace to delete it. After completing SetText your Editable Text back to the changed one.
Remember to store your EditableText into a String Variable, too.

Like the first one… But don´t check if the Text contains a string… just use replacement on every forbidden word.

​​​​​​​Depending on how long your Wordlist is… 1st or 2nd is more performant…

Thanks for the reply!

I’m just a little confused on how it’s supposed to be set up/connected. Do you think you can show me an example or screenshot of the first way?

Sure… here is an example of how to do a Number only Input (only allow numerical Inputs with or without “.” or “,”).
Important if you wanna copy this: I created a LocalVariable inside the Function, called “NumHolder”, to store the outcome before returning.

And here is, how to use this Function:

On TextCHanged, i check against the Text, if it only includes numerical signs (without ./,), to return an Integer Value only.

So, you may ask, how to check against words now…
A new Function like my GetNumeric above… I calll it “GetTrusted”.
We remove the Integer return and only use a String as Input and Outcome.
We also need a Variable String Array, i call it “BlackList” and this will be filled with all the bad Words, Phrased or other Signs and Stuff.
AND, that is important, we use a Local Variable. Within Functions, you can create Local Variables at the Bottom of the Variable Panel. I call it “WordHolder” and make it a String Array.

You are filling the BlackList by yourself. If you need it globally (in every Widget, Actor or else), put this BackList Variable into GameInstance and use

GetGameInstance -> CastTo CustomGameInstance -> Get[BlackList]

If your BlackList contains the Word “Numbatz” and a Player is writing it… he can write “Numb atz” or “N umbatz” as he wishes… since this only checks against the full word. This is just an example of how to make a Type->Check->Correct System works.
If he writes out “Numbatz”, the word will be deleted right away.

I really appreciate your in-depth and informative examples. But, the second example (checking against words) isn’t working for me. I’m not sure if it’s because the function Get Trusted isn’t binded to anything or not. Do you know what it could be?