Multi-line text box character number length verification solution!

xiaoxiao2021-03-06  40

In the ASP.NET system, you will often encounter the length of the verification text, such as VARCHAR (50) in the database, so it is best to control only 50 characters on the interface, this verification is essential in some cases. :

For a single line text box, use the length attribute, this method is simple, but there is a problem, it is Chinese characters that only records only one character, and two characters in the database, so it is like the above 50 characters, if used Length = 50, if the user enters 50 Chinese characters, then the system will report an error, so length = 25 can be used to control the maximum possibility, which also reduces the word number of English characters. This is also important, as long as we are in designing the database, you can magnify the number of numbers that should be needed.

It doesn't work for the Length attribute of multi-line text boxes, so the following scenarios should be used: