Coming in close contact with anything magnetic can erase the information encoded on the magnetic strip. If your credit card is on the counter while a cashier is deactivating the security device on a new compact disc, for instance, the strip can become demagnetized.
Coming into contact with refrigerator magnets, clasps on wallets, and magnets on the back of tape measures and flashlights can demagnetize a credit card.
Items with strong electromagnetic fields also can ruin credit card strips. For example, it's best not to set cell phones or digital cameras near credit cards.
A credit card can also get demagnetized if the strip gets extremely scratched.
If you want to demagnetize the strip for safety reasons because you only use the card for online purchases and not in card machines, you can simply rub a magnet over the strip for a minute or so.