I would like to use jquery to append text onto what the user has typed in a text box, while the user is typing.
Say I wanted to append " is a hat" to the end of what the user typed.
Lets say the user starts typing "My Friend" into the field.
As they type the box will read:
M -> M is a hat
y -> My is a hat
-> My is a hat
F -> My F is a hat
r -> My Fr is a hat
...
I started writing a function for the keypress event, but then I realized that I would end up with something like
M -> M is a hat
y -> M is a haty is a hat
...
So what I want to know is how I should
- Replace the old suffix
- Place the cursor back to where the user was typing
- Make sure they only are able to type before the suffix, so they they can't edit the suffix