Fixed - thanks Ray
Problem resolved through support call.
Here is the amended function which allows validation of AUS/NZ postcodes, which are all 4 digit I believe...
When calling the function, remember you will need an extra parameter
function WAValidateZCNew($value,$us5,$us9,$can6,$uk,$anz,$required,$number) {
$WAFV_ErrorMessage = "";
$isValid = true;
$allowed = "() -.\n\r";
$charVal = "";
if (!(!$required && $value=="")) {
$newVal = "";
$hasLetters = false;
for ($x=0; $x < strlen($value); $x++) {
$z = substr($value, $x, 1);
if (($z >= "0") && ($z <= "9")) {
$newVal .= $z;
$charVal .= "N";
}
else if (($uk || $can6) && ((($z >= "a") && ($z <= "z")) || (($z >= "A") && ($z <= "Z")))) {
$charVal .= "A";
$hasLetters = true;
}
else if (strpos($allowed, $z) < 0 || $x == 0 || $x == strlen($value)-1) {
$isValid = false;
}
}
$acceptPattern = ",";
if ($anz) {
$acceptPattern .= "NNNN,";
}
if ($us5) {
$acceptPattern .= "NNNNN,";
}
if ($us9) {
$acceptPattern .= "NNNNNNNNN,";
}
if ($uk) {
$acceptPattern .= "ANNAA,ANNNAA,AANNAA,AANNNAA,ANANAA,AANANAA,";
}
if ($can6) {
$acceptPattern .= "ANANAN,";
}
if (strpos($acceptPattern,",".$charVal.",") === false)
$isValid = false;
if ($isValid && !$hasLetters && ($us5 || $us9 || $anz)) {
if ($anz) {
$isValid = preg_match('/^\d{4}$/', $value);
}
if ($us5 && !$isValid) {
$isValid = preg_match('/^\d{5}$/', $value);
}
if ($us9 && !$isValid) {
$isValid = (preg_match('/^\d{5}[-\. ]\d{4}$/', $value) || preg_match('/^\d{9}$/', $value));
}
}
}
if (!$isValid) {
$WAFV_ErrorMessage .= ",".$number;
}
return $WAFV_ErrorMessage;
}
?>