Custom text formatting for input component?

Hi guys, I have a regular text component where people have to enter a certain account number, similar to this: AB 1234 1234

How can I setup the component in a way, so that it gets automatically formatted like that? I want to type in AB12341234 but it should display as AB 1234 1234. But the actual value of course should be without the empty spaces, I want to save it as AB12341234

Is that possible?