Prohibit input of words - question

By: Michael Lang | Asked: 02/10/2023
ForumsCategory: General questionsProhibit input of words - question
Michael Lang asked 2 years ago
Hello I have a question if anyone had the same problem and was able to solve it? I wanted to prohibit entering 2 words in a field, which works. Code looks like this: ^(?!.*\b(bochum|Bochum|unbekannt|Unbekannt)\b)[a-zA-Z0-9]+$ (inserted in the text field under format)
Now I have the following problem that words with Ä,Ö,ß and so on can no longer be entered. Does anyone have a tip an idea?
2 Answers
Best Answer
Victor Font answered 2 years ago
Your regex is not accounting for Unicode characters. I am not a regex expert by any stretch of the imagination. Maybe this will help: https://www.regular-expressions.info/unicode.html
Michael Lang replied 2 years ago

Thanks gave me an idea.

In case someone needs this to ban words in a field:

"^(?!.*\b(word|Word|example|Example)\b)[a-zA-Z0-9-Ä-ä-Ü-ü-Ö-ö-ß]+$"

Chris Titus answered 2 years ago
You might use the same logic found here - https://formidableforms.com/knowledgebase/general-form-settings/#sts=Restrict%20email%20addresses
Michael Lang replied 2 years ago

Hello thanks for the tip, since the form is multi-page, the submit button is not so good, it should already happen on the first page.

The code would be wonderful if the umlauts would work, unfortunately I have no further idea how to adapt it for this.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right