Change textbox value

Guys, I’ve seen a lot of this on websites to change passwords: the first letter of the name followed by an asterisk or “x” @domain.
I wanted to do this with numbers. In Brazil we use the CPF and I would like it if the user writes in the textbox that only the first three digits and the last two appear. Example: 548.156.478-00
With asterisks:
548.***.-00. When he edited it he would go back to what he was before.

This code was created to include dots and dashes in the CPF.

And to record in firebase I remove the formatting