Limit Textbox to only accept strings and numbers (no special characters)

I want to limit the user input to a textbox only to allow strings from a-z (A-Z), numbers, and space or underscore. This textbox is for a filename and the limitation is for avoiding errors in saving data to a filename that is created based on the text from this textbox. So that user can't enter / or \ or other characters that are not allowed in filenames.

Or maybe a function to scan the string from a textbox before creating the filename and removing unwanted characters?

Probably with use of a Kevinkun's regex extension and Taifun's Textbox extension

Regex example: [^A-Za-z0-9]+/g


perhaps something like this :slight_smile: