I'm trying to extract the first part of a UK postcode using an if/else from the full postcode in javascript
Basically, if the postcode is in the format;
AB99 9CD
it needs to return AB
A9 9BC
it needs to return A
A99 9BC
it needs to return A
AB9C 9DE
it needs to return AB
.
I thought about trying
if (fieldname == LETTER1 LETTER2 NUM NUM NUM LETTER3 LETTER 4)
return LETTER 1 LETTER 2;
and so on, then using the else as the error message, so that it's recognising the format & returning the first one or two letters but haven't got a clue what code to use.
Aucun commentaire:
Enregistrer un commentaire