Menu
Hello,
I am trying to validate the first part of a uk postcode(post out) which has the following permetations AN / AAN / ANN / AANN. A(ALPHA) N(nUMERIC). I have managed to find a regular expression on a forum based on the the full uk postcode not just my requirement of the first part as with the above permetations. As i am not 100% sure of the expression’s syntax i was wondering if anyone could alter it to test only for the first part with the above permetations??
function isValidPostcode(postcode) {
if (!/^[A-Z]{1,2}d{1,2} d[A-Z]{2}$/.test(postcode)) {
return false;
}
return true;
}
Thanks in advance