salonbookingsystem

Codice Fiscale - validazione

Mar 17th, 2022 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter('sln.shortcode.details.dispatchForm.validate_bind_values', function ($isValid, $values, $step) {
  2.         if (isset($values['codice_fiscale'])) {
  3.             $codiceFiscale = $values['codice_fiscale'];
  4.             $pattern = "/^[A-Za-z]{6}[0-9LMNPQRSTUV]{2}[A-Za-z]{1}[0-9LMNPQRSTUV]{2}[A-Za-z]{1}[0-9LMNPQRSTUV]{3}[A-Za-z]{1}$/i";
  5.             if (strlen($codiceFiscale) !== 16 || !preg_match($pattern, $codiceFiscale)) {
  6.                 $step->addError(__('Codice fiscale errato', 'salon-booking-system'));
  7.                 $isValid = false;
  8.             }
  9.         }
  10.  
  11.         return $isValid;
  12.     }, 10, 3);
Add Comment
Please, Sign In to add comment