How do I set a maximum character limit to my textbox C#?

I have a textbox where users are promted to input a desired username, but they are able to set an unlimited amount of characters, which I only want to allow 18. How can I do this within C#?

Please read the script reference: Unity - Scripting API: GUI.TextField

The second constructor for textfield has builtin what you want.