Accidents are inevitable but if you act quickly you may well avoid a permanent stain. Just follow this guide from the NCCA to deal with all the common stains:
If something gets spilt on to your carpet, prompt action is required to prevent staining.
We recommend having the following items and solutions to hand for dealing with spillages as soon as possible:
Clean white absorbent cloth or towel
Dry Cleaning Solution
Surgical Spirit (usually available from local Chemists)
Useful for: solids, fats, tar, chewing gum, oil, ointment, shoe polish and unknown stains. Then follow with a detergent vinegar solution.
One teaspoonful of gentle detergent for washing woollens, to half a pint (0.3 litres) of warm water
Useful for: chocolate, sweets, blood, glue, egg, ice cream, milk, soft drinks, vomit and unknown stains that require further treatment. Follow with an ammonia solution.
Detergent Vinegar Solution
Add one teaspoonful of white (not malt) vinegar to the Detergent Solution
Useful for: alcohol, coffee, tea, liquid foods, and urine.
One teaspoonful of branded household Ammonia (available from hardware stores) to one cup of warm water