Blot up as much of the dye as possible with white paper towels. The thicker and more absorbent the brand, the better.
Generously cover the stain with corn starch. Allow it to sit for about 15 minutes, then sweep or vacuum it up. The corn starch will remove the excess dye from the carpet.
Spray shaving cream on top of the spot, then sprinkle on a few drops of water. Work the cream into the carpet with your fingers.
Blot the area well with paper towels or a white cloth.
If any stain remains, mix 1 tablespoon of ammonia with 1/2 cup of water. Wet the stain well with the solution and blot to dry.