simply limit your INPUT form field to 6 chars or whatever, using MAXLENGTH="6" .
that will only allow you to type 6 chars. but its always good to make a check on server side too, as someone can try to cpy the url and make their own form, and enter more data in and submit it .. 🙂 hacking i mean.
so use strlen() to count the number of chars in the string, and if its more then raise error.. thats it!