This is one example: https://github.com/bokkypoobah/TokenTrader/blob/master/contr...
Originally asked here: https://ethereum.stackexchange.com/questions/12757/detect-or...
You can also check with MyEtherWallet: https://ethereum.stackexchange.com/questions/21082/use-mew-f...
The short answer is that you need the contract code and ABI to check if it is a ERC20 compliant token or not but you can use http://testnet.etherscan.io/ (or the live version) to get this information.