0

So, I'm making a form with an input for the username which doesn't allow bad words

 <input pattern="^((?!swearword)(?!racism)(?!homophobic).)*$" title="No bad words, please" />

How can I add case sensitivity to the pattern, and, is this the best way to exclude bad words?

  • Not sure if there is a way to use [*ignore case* in the pattern attribute](https://stackoverflow.com/questions/5524842/have-html5s-a-inputs-pattern-attribute-ignore-case). Probably you would need to write out all options `[Aa][Bb][Cc]`... something [like this](https://regex101.com/r/KGhEbk/1). Maybe more comfortable to check the input by a more poweful JS function or even after submission by serverside script. – bobble bubble Nov 11 '22 at 13:19
  • 1
    Thanks, I added a JS function. const regex = new RegEx("regex", "i") something like that – Brizuela Go Nov 12 '22 at 02:03

0 Answers0