I started to evaluate PS yesterday and it seems really good other than this postcode issue that came to light in my first test.
Like everyone else, I've had a google and there doesn't seem to be a sensible solution ready to hand.
I've cribbed together my own fix which, with the postcodes I've already tried, seems to work ok. I'm sure someone out there will find a postcode that this doesn't work for. If that is the case - then just modify and add an additional regex.
My solution.
Back up the file js/validate.js
then modify the validate_isPostCode function to read:
function validate_isPostCode(s, pattern, iso_code)
{
if (typeof iso_code === 'undefined' || iso_code == '')
iso_code = '[A-Z]{2}';
if (typeof(pattern) == 'undefined' || pattern.length == 0)
pattern = '(([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))';
else
{
var replacements = {
' ': '(?:\ |)',
'-': '(?:-|)',
'N': '[0-9]',
'L': '[a-zA-Z]',
'C': iso_code
};
for (var new_value in replacements)
pattern = pattern.split(new_value).join(replacements[new_value]);
}
var reg = new RegExp('^' + pattern + '$');
return reg.test(s);
}
Like I say, this seems to work for me......hope it helps.