• 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: Codice Fiscale validation

Codice Fiscale validation 13 years 7 months ago #15227

  • pursomando
  • pursomando's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 3
I would share the source to add the "codice fiscale validation" into your form...this can be useful to italian to add the Codice Fiscale field in registration form.

Add this function in /components/helpers/validation.php:
function CodiceFiscale($param,$extra=null){
if( $param == '' ) return false;
if( strlen($param) != 16 )
return false;
$param = strtoupper($param);
if( ! ereg("^[A-Z0-9]+$", $param) ){
return false;
}
$s = 0;
for( $i = 1; $i <= 13; $i += 2 ){
$c = $param[$i];
if( '0' <= $c && $c <= '9' )
$s += ord($c) - ord('0');
else
$s += ord($c) - ord('A');
}
for( $i = 0; $i <= 14; $i += 2 ){
$c = $param[$i];
switch( $c ){
case '0': $s += 1; break;
case '1': $s += 0; break;
case '2': $s += 5; break;
case '3': $s += 7; break;
case '4': $s += 9; break;
case '5': $s += 13; break;
case '6': $s += 15; break;
case '7': $s += 17; break;
case '8': $s += 19; break;
case '9': $s += 21; break;
case 'A': $s += 1; break;
case 'B': $s += 0; break;
case 'C': $s += 5; break;
case 'D': $s += 7; break;
case 'E': $s += 9; break;
case 'F': $s += 13; break;
case 'G': $s += 15; break;
case 'H': $s += 17; break;
case 'I': $s += 19; break;
case 'J': $s += 21; break;
case 'K': $s += 2; break;
case 'L': $s += 4; break;
case 'M': $s += 18; break;
case 'N': $s += 20; break;
case 'O': $s += 11; break;
case 'P': $s += 3; break;
case 'Q': $s += 6; break;
case 'R': $s += 8; break;
case 'S': $s += 12; break;
case 'T': $s += 14; break;
case 'U': $s += 16; break;
case 'V': $s += 10; break;
case 'W': $s += 22; break;
case 'X': $s += 25; break;
case 'Y': $s += 24; break;
case 'Z': $s += 23; break;
}
}
if( chr($s%26 + ord('A')) != $param[15] )
return false;
return true;
}
The administrator has disabled public write access.
The following user(s) said Thank You: alexp, pirra, francesco.facciolo0

Re: Codice Fiscale validation 13 years 7 months ago #15258

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Thank you for your contribution!
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Codice Fiscale validation 9 years 6 months ago #33130

I really wanted to say thank-you for providing the above code for the CF check. This was immensely appreciated and saved me a lot of time!

Regards

Andrea.
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!