Yep, this is known as input masking, and I wish browsers would just natively support this through various input types, because it's been the bane of my existence.
Phone inputs are especially painful to mask since you have to deal with a mind-boggling number of format variations.