Fixed the caret position on the patterned input