• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Validation Vat ID

Validation Vat ID 4 years 3 weeks ago #41228

I have found the following regex table for the validation of the VAT-ID
'AT': (/^(AT)(U\d{8}$)/i),                                   // Austria
'BE': (/^(BE)(\d{10}$)/i),                                   // Belgium
'BG': (/^(BG)(\d{9,10}$)/i),                                 // Bulgaria 
'CY': (/^(CY)([0-5|9]\d{7}[A-Z]$)/i),                        // Cyprus
'CZ': (/^(CZ)(\d{8,10})?$/i),                                // Czech Republic
'DE': (/^(DE)([1-9]\d{8}$)/i),                               // Germany 
'DK': (/^(DK)(\d{8}$)/i),                                    // Denmark 
'EE': (/^(EE)(10\d{7}$)/i),                                  // Estonia 
'EL': (/^(EL)(\d{9}$)/i),                                    // Greece 
'ES': (/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i),                 // Spain
'EU': (/^(EU)(\d{9}$)/i),                                    // EU-type 
'FI': (/^(FI)(\d{8}$)/i),                                    // Finland 
'FR': (/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i),                      // France
'GB': (/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i), // UK (Standard = 9 digits), (Branches = 12 digits), (Government = GD + 3 digits), (Health authority = HA + 3 digits)
'GR': (/^(GR)(\d{8,9}$)/i),                                  // Greece 
'HR': (/^(HR)(\d{11}$)/i),                                   // Croatia 
'HU': (/^(HU)(\d{8}$)/i),                                    // Hungary 
'IE': (/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i),                // Ireland
'IT': (/^(IT)(\d{11}$)/i),                                   // Italy 
'LV': (/^(LV)(\d{11}$)/i),                                   // Latvia 
'LT': (/^(LT)(\d{9}$|\d{12}$)/i),                            // Lithunia
'LU': (/^(LU)(\d{8}$)/i),                                    // Luxembourg 
'MT': (/^(MT)([1-9]\d{7}$)/i),                               // Malta
'NL': (/^(NL)(\d{9}B\d{2}$)/i),                              // Netherlands
'NO': (/^(NO)(\d{9}$)/i),                                    // Norway (not EU)
'PL': (/^(PL)(\d{10}$)/i),                                   // Poland
'PT': (/^(PT)(\d{9}$)/i),                                    // Portugal
'RO': (/^(RO)([1-9]\d{1,9}$)/i),                             // Romania
'RU': (/^(RU)(\d{10}$|\d{12}$)/i),                           // Russia
'RS': (/^(RS)(\d{9}$)/i),                                    // Serbia
'SI': (/^(SI)([1-9]\d{7}$)/i),                               // Slovenia
'SK': (/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i),                // Slovakia Republic
'SE': (/^(SE)(\d{10}01$)/i)                                  // Sweden

I have created a customvalidation.php and entered the following code, unfortunately it does not work. What am I doing wrong?
 
<?php
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
require_once dirname(__FILE__).'/validation.php';
 
class RSFormProCustomValidations extends RSFormProValidations
{
 
public static function vatid($value, $extra = null, $data = null)
	{
		if (!$value)
			return false;
 
		if (preg_match("/(AT)(U\d{8}$)/", $value))
			return true;
 
		if (preg_match("/(BE)(\d{10}$)/", $value))
			return true;
 
		if (preg_match("/(BG)(\d{9,10}$)/", $value))
			return true;
 
		if (preg_match("/(DE)([1-9]\d{8}$)/", $value))
 
		if (preg_match("/(EE)(10\d{7}$)/", $value))
			return true;
 
		return false;
	}
}
 

Thanks in advance
The administrator has disabled public write access.

Validation Vat ID 4 years 2 weeks ago #41241

Hi,
I have found the solution,
 
<?php
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
require_once dirname(__FILE__).'/validation.php';
 
class RSFormProCustomValidations extends RSFormProValidations
{
	public static function vatID($value, $extra = null, $data = null) // VAT-ID EU
	{
		if (!$value)
			return false;
 
		if (preg_match( '/^(AT)U(\d{8})$/', $value ))					// AUSTRIA
			return true;
 
		if (preg_match( '/(BE)(0?\d{9})$/', $value))					// BELGIUM
			return true;
 
		if (preg_match( '/(BG)(\d{9,10})$/', $value))					// BULGARIA
			return true;
 
		if (preg_match( '/^(CY)([0-5|9]\d{7}[A-Z])$/', $value))			// CYPRUS
			return true;
 
		if (preg_match( '/^(CZ)(\d{8,10})(\d{3})?$/', $value))			// CZECH REPUBLIC
			return true;
 
		if (preg_match( '/^(DE)([1-9]\d{8})/', $value))					// GERMANY
			return true;
 
		if (preg_match( '/^(DK)(\d{8})$/', $value))						// DENMARK
			return true;
 
		if (preg_match( '/^(EE)(10\d{7})$/', $value))					// ESTONIA
			return true;
 
		if (preg_match( '/^(EL)(\d{9})$/', $value)||preg_match( '/^(GR)(\d{8,9})$/', $value))	// GREECE
			return true;
 
		if (preg_match( '/^(ES)([A-Z]\d{8})$/', $value)||preg_match( '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/', $value)||preg_match( '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/', $value)||preg_match( '/^(ES)([K|L|M|X]\d{7}[A-Z])$/', $value))		// SPAIN
			return true;
 
		if (preg_match( '/^(EU)(\d{9})$/', $value))						// EU type
			return true;		
 
		if (preg_match( '/^(FI)(\d{8})$/', $value))						// FINLAND
			return true;		
 
		if (preg_match( '/^(FR)(\d{11})$/', $value)||preg_match( '/^(FR)([(A-H)|(J-N)|(P-Z)]\d{10})$/', $value)||preg_match( '/^(FR)(\d[(A-H)|(J-N)|(P-Z)]\d{9})$/', $value)||preg_match( '/^(FR)([(A-H)|(J-N)|(P-Z)]{2}\d{9})$/', $value))	// FRANCE
			return true;		
 
		if (preg_match( '/^(GB)?(\d{9})$/', $value)||preg_match( '/^(GB)?(\d{12})$/', $value)||preg_match( '/^(GB)?(GD\d{3})$/', $value)||preg_match( '/^(GB)?(HA\d{3})$/', $value))				// GREAT BRITAIN
			return true;		
 
		if (preg_match( '/^(HR)(\d{11})$/', $value))				// CROATIA
			return true;		
 
		if (preg_match( '/^(HU)(\d{8})$/', $value))					// HUNGARY
			return true;
 
		if (preg_match( '/^(IE)(\d{7}[A-W])$/', $value)||preg_match( '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/', $value)||preg_match( '/^(IE)(\d{7}[A-W][AH])$/', $value))			// IRELAND
			return true;
 
		if (preg_match( '/^(IT)(\d{11})$/', $value))				// ITALY
			return true;
 
		if (preg_match( '/^(LV)(\d{11})$/', $value))				// LATVIA
			return true;
 
        if (preg_match( '/^(LT)(\d{9}|\d{12})$/',$value))			// LITHUNIA
            return true;
 
        if (preg_match( '/^(LU)(\d{8})$/',$value))					// LUXEMBOURG
            return true;
 
        if (preg_match( '/^(MT)([1-9]\d{7})$/',$value))				// MALTA
            return true;
 
        if (preg_match( '/^(NL)(\d{9})B\d{2}$/',$value))			// NETHERLAND
			return true;
 
        if (preg_match( '/^(NO)(\d{9})$/',$value))					// NORWAY
            return true;
 
        if (preg_match( '/^(PL)(\d{10})$/',$value))					// POLAND
            return true;
 
        if (preg_match( '/^(PT)(\d{9})$/',$value))					// PORTUGAL
            return true;
 
        if (preg_match( '/^(RO)([1-9]\d{1,9})$/',$value))			// ROMANIA
            return true;
 
        if (preg_match( '/^(RS)(\d{9})$/',$value))					// SERBIA
            return true;
 
        if (preg_match( '/^(SI)([1-9]\d{7})$/',$value))				// SLOVENIA
            return true;
 
        if (preg_match( '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/',$value))// SLOVAK REPUBLIC
            return true;
 
        if (preg_match( '/^(SE)(\d{10}01)$/',$value))				// SWEDEN
        return true;
	}
}
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!