First, what is this input used for?
if it is for a verification or something like this, I think you can make two text box with limited length of input.

If you just want to use 1 text box, you must use javascript (I think). Coz as far as I know, HTML is just used for designing website, it's not a programming language.

HTML -> HyperText Markup Language