Unfortunately, especially for e-commerce systems, there isn't a simple way to check the validity of a European VAT number. The European Commission provides a web site where you can validate VAT numbers by entering them in an HTML form. This is not practical, of course, for web applications.
Enter, the European VAT Number Validation API that I just hacked together on Google App Engine.
european_union_countries = ('AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB',)