Download

I made a text box to prohibit the input of certain types of characters

[FONT=等线]I made a text box to prohibit the input of certain types of characters
[FONT=等线]In fact, I had a problem and wanted help. The question comes after I explain what I’ve done so far.


[FONT=等线]As shown in the figure, I made a function, which is called when the text box changes. If illegal characters are encountered, the illegal characters will be automatically deleted and updated to the text box. In fact, illegal characters may be hundreds of times as many as legal characters, so I use reverse thinking to list the types of legal characters, such as uppercase letters, lowercase letters, numbers, punctuation marks, Chinese punctuation (in simplified Chinese, punctuation is Chinese character code), simplified Chinese characters, etc., and then mark some very special illegal characters.

Inside the function, I set some local fstring variables to store legal characters.
QQ截图20200912184442.png
Then, according to the input Boolean value, the legal characters are spliced together, and the illegal characters are ignored.

This will result in an fstring LegalAlphabetList containing all legal characters.Then split the input string into a single character B[n], and try to find out whether LegalAlphabetList contains B[n].Append the B[n] contained by a into a temporary string Temp in the original order.


Then the ‘illegal character’ fstring is split into a single character C [n], and each C [n] in the temp is replaced with a null character.

Finally, check whether the length exceeds the limit and return temp.

Well, the problem is that there are thousands of Chinese characters, not just 26 letters. It is unacceptable to add Chinese characters to the LegalAlphabetList and query whether they are included. The solution I have come up with is as shown in the figure. How many values should be filled in the figure?