You can do this with javascript. I'm not a javascript expert but this is how I'd do it:
Add an onkeypress event to the input field. When the event fires check the length of the value and modify the width of the field if the number of characters exceeds a certain limit.