Immediately after you've erased the card (and I mean, IMMEDIATELY), turn off the camera and remove the erased card. Screaming "oh sh!t oh sh!t oh sh!t"/pounding your head against a wall/slapping yourself is optional.
Quarantine the card - keep it separate from your other cards until you get back to your computer. This is very important - Do not record anything else to that card until after you have recovered your images from it.
Use file recovery software - there are a number of programs out there that can recover erased images. We use the Sandisk Extreme brand of CompactFlash and SDXC cards, which come with a free file recovery program called Rescue Pro.
This software has
Formatting erases the catalog on the card that tells the computer where the images are on the card. The images are still on the card until they are overwritten by another image. As long as you do not record anything onto an accidentally formatted card, you stand a good chance of recovering what you lost.