hi
i have custom validation for field of user registration and it can't use with Regex because it's little complex.
how can i use my php code?
i find auto action solution and i select OnbeforeRgistration trigger and what type must select for validation? Code type must select? or Field ?
my phpValidation code:
Code:
function isValidCustomCode($input) {
# check if input has 10 digits that all of them are not equal
if (!preg_match("/^\d{10}$/", $input)) {
return false;
}
$check = (int) $input[9];
$sum = array_sum(array_map(function ($x) use ($input) {
return ((int) $input[$x]) * (10 - $x);
}, range(0, 8))) % 11;
return ($sum < 2 && $check == $sum) || ($sum >= 2 && $check + $sum == 11);
}
tnx