Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Ballymena, N.Ireland
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    UK Postcode Validation

    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 this 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

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    doesn't use RegEx, but may be just what you want. seems to work just fine.

    >>UK Postcode Validation
    *keep it simple (TM)

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    also, from Google:

    >>javascript uk postcode validation
    *keep it simple (TM)

  • #4
    New Coder
    Join Date
    Aug 2002
    Location
    Ballymena, N.Ireland
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jbot,

    Thank you. I have managed to see how to do it.

    Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •