SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Format a postcode

    Hi,

    How can I format a postcode in a field so that it always appears in upper case and has a space between characters 3 and 4. E.g. BL99NB would need to be formatted like BL9 9NB automatically.

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not all UK postcodes are formatted that way.

    Example post codes:
    - TW10 2FF
    - EH6 7FZ‎
    - W1

    Instead of formatting the data on the client-side I would suggest letting the user enter what they want and then you can process it how you see fit on the server-side.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Agreed, plus are you only targeting people from the UK? Because in America and other countries they use a completely different system known as zip codes (and have no postal code) so unless you are only targeting a limited number of countries you might want to rethink your naming structure too.

  4. #4
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your advice.


Bookmarks

Posting Permissions

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