When you create a new sys_dictionary record to define a new string field, the max_length is mandatory. Despite the similarity of the name to HTML's maxlength attributes for input or textarea tags, this is not enforced as a limit in the client or server.
Max length is not enforced in ServiceNow
Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value.
This is expected behavior of the product.
When you create a string field in ServiceNow, the underlying column in database is created with a default data type based in part on the specified max_length value.
Small (40) = varchar(40)
Medium (100) = varchar(100)
Large (1000) = mediumtext
Extra Large (4000) = mediumtext
Any string field that is larger than varchar(255) is given the mediumtext data type. In the client, it will be represented as HTML textarea, instead of an HTML input. The maximum length of mediumtext is 16,777,215 bytes.
In terms of restricting the number of characters stored in the field, this is controlled by the database and not restricted by the product. For example, if the field has been changed in the database to varchar(45), you can enter 45 characters in the input box. It does not matter if max_length is still set at 40, or has been otherwise modified to a different value.
Similarly, if you are importing data, if the database column is larger than the max_length value, you can import values up to the size limit of the database column. Again, max_length will not cause truncation of the imported value.
There are recurring questions about enforcing the max_length of 4000 characters on either or both of the comments/work_notes fields for task. These fields support the input of HTML with the use of [code][/code] tags.