Announcement

Collapse
No announcement yet.

Force Postcode Into Capitals

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Force Postcode Into Capitals

    I have followed the AUG to Automatically Capitalise Customer Input which seems to have worked fine, Until it comes to the Postcode which is only capitalizing the 1st letter when all the letters should be capitals - a space between the numbers would be nice too!! (XX9 9WW)

    But what is the wording to replace the

    onchange="this.value = capitalizeWords(this.value)"
    (presume its the - capitalizeWords I need to change)

    Or am i barking up the wrong tree?

    I have searched the forum and can't seem to find what I am looking for with version 8.

    Any help wuld be appriciated

    #2
    Hi,

    This is a lot simpler, as the only process required is to turn the whole content in to capitals and does not need any individual character processing. Try inserting the following function below the existing function:


    HTML Code:
    function capitalizePostCode(string) { 
     var tmpStr ;
     tmpStr = string.toUpperCase();
     return tmpStr;}
    Then in the appropriate input tag, replace the existing:

    HTML Code:
    onchange="this.value = capitalizeWords(this.value)"
    with:
    HTML Code:
    onchange="this.value = capitalizePostCode(this.value)"
    a space between the numbers would be nice too!! (XX9 9WW)
    The inclusion of spaces in postcodes is another matter!! While a legal Postcode must contain a space at the correct point, it is very hard to establish where in a non-spaced postcode the space should go. Take the following example:

    RG23PN

    Did the user mean to enter RG2 3PN or did they mean to enter RG23 ?PN but did so incorrectly. You are better of validating the user input and informing them if it is incorrect IMO. If you decide to go down this route there are many Postcode validation scripts on the internet, just be sure to test them for accuracy and correctness

    HTH

    Chris
    Ladies Swimwear
    www.li-fi.co.uk

    Comment


      #3
      Thank you for the reply but can you be precise in relation to the Javascript in the AUG exactly where to input

      function capitalizePostCode(string) {
      var tmpStr ;
      tmpStr = string.toUpperCase();
      return tmpStr;}

      I need it in black & white!!

      Thanks

      Comment


        #4
        Try this thread:-

        http://community.actinic.com/showthread.php?t=19468
        Brian
        www.flowergallery.co.uk
        Same day flower delivery to UK
        Same day flower delivery to Republic of Ireland
        International Flower Delivery

        Located in Argyll, Scotland, UK

        Comment


          #5
          Hi CraftJoy,

          Having looked at the thread suggested by Brain (above), the better solution is to do as it suggests and instead of inserting the new function, just include the following:

          HTML Code:
          onblur="this.value=this.value.toUpperCase()"
          - Thanks for pointing that out Brian..its a much better way to do the same thing

          However, if you want to continue with the original suggestion then look for the existing code that reads:

          HTML Code:
          return tmpStr; 
          }
          // -->
          and insert the new function:
          HTML Code:
          return tmpStr; 
          }
          INSERT THE NEW FUNCTION HERE
          
          // -->
          HTH

          Chris
          Ladies Swimwear
          www.li-fi.co.uk

          Comment


            #6
            Spaces between postcodes is easy to decide (at least for the UK). The space always goes before the last three characters.
            The problem comes when you accept international orders as you then end up with spaces where there shouldn't be any.

            Mike
            -----------------------------------------

            First Tackle - Fly Fishing and Game Angling

            -----------------------------------------

            Comment


              #7
              Spaces between postcodes is easy to decide (at least for the UK). The space always goes before the last three characters.
              Very true, but as my above example demonstrates, if you were to follow this rule and re-format the postcode to be RG2 3PN and the user actually meant to enter RG23 ?PN (but did so incorrectly), the resulting postcode will be correctly formatted but will still be incorrect for the given address. Therefore, you are far better to provide the user with a useful message and allow them to correct the error. If they do this and the postcode is still incorrect for the address, there is nothing you can do
              Ladies Swimwear
              www.li-fi.co.uk

              Comment

              Working...
              X