How restricting the number of characters in a input text box?

I used a slightly simplified version of your solution to great effect. Thanks for the bp!