Hi Meria,
There is no such thing as a silly question!!
All questions helps in some way!
I took some time to make a better sample for you the idea was to replace, for example, the user input.
What I did in this sample, was using Regex not as a Pattern in the input, because it would not prevent the user from typing, but using it to replace the text every time the user types a value.
I did not used the OnChange event, I made it independent so you can use both.
See:

I added an Input Parameter to the custom DropDown widget where you can inform a regex Pattern.
In this case it will not allow anything that is not numbers, letters from a-Z and white spaces.
How I did that?
I just added in the Init Function where the Javascript is initialized the follow code:

I check if the pattern exists, and add a Listener, so every time the user type something I can replace if there are something that I don't want:)
This was taken from here, it will explain a little bit better if you want
See if this is what you are looking for,
Cheers and Regards,
RR :)