Very complicated case. I implemented this a year and a half ago. What I ended up doing was using 4 textfields, and checking after each change in each textfield, if the content is empty (a character was deleted) then go back to the previous one, while if there is a character, go to the next one.
It gave me headache.