Hairballs can irritate the stomach, causing cats to vomit. The vomit may or may not contain the hairball. Hairballs can also pass into the intestines, where they can harden and lead to constipation or even intestinal obstruction.
A diagnosis of hairballs is usually based on history and clinical signs. Your veterinarian may recommend an x-ray if your cat is showing signs of constipation or obstruction.
Initial treatment includes laxatives that help lubricate the hairball so that it can pass more easily. These are usually sold as tubes of paste that most cats find very tasty. Your vet will advise you on how much of the paste to give to your cat. In severe cases with signs of intestinal obstruction, surgery may be needed to remove the hairball.
Prevention involves periodic use of paste laxatives. There are also commercial diets that are specially formulated to minimize this problem. Brushing your cat regularly to remove loose hair also helps to minimize formation of hairballs.