valid JPG checking.....how do I do that?

I am having a small problem checking for valid (complete) jpgs as I am loading
and displaying them.  I can't seem to think of some way to do that without
checking the byte count against computed size based off of the header info.  
However, this wouldn't catch anything that has the same count but is still not
a valid jpg.  Does anyone have any ideas?

Shaun
sam...@telusplanet.net