Announcement

Collapse
No announcement yet.

Capatalize words script but how.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I had it in earlier

    Have put it back

    now i am back to the county not capitalising


    I will go down the style route any way but seems odd
    David

    Comment


      #17
      All up and running with he style method

      removed all the Jarva,


      works a treat

      Thank you Norman
      David

      Comment


        #18
        I'm also using the 'style' method for capitalisation. Very nice thank you Norman.

        For postcodes, I'm using javascript to do the formatting (makes it all upper case and puts the space in the right place). To use this put this code:

        <script type="text/JavaScript">
        <!--
        function formatPostCode(string) {
        var tmpString, inward, outward, postcode;
        tmpString = string.replace(/ /g,"");
        tmpString = tmpString.toUpperCase();
        inward = tmpString.substring(tmpString.length - 3);
        outward = tmpString.substring(0, tmpString.length - 3);
        postcode = outward + " " + inward;
        return postcode;
        }
        // -->
        </script>

        in the head of your template and then add the following:

        onchange="this.value=formatPostCode(this.value)"

        into the postcode input so that it now says:

        <INPUT TYPE="TEXT" NAME="INVOICEPOSTALCODE" SIZE="10" MAXLENGTH="50" VALUE="NETQUOTEVAR:INVOICEPOSTALCODE" onchange="this.value=formatPostCode(this.value)">

        Mike
        Last edited by Mike Hughes; 16-Dec-2004, 12:53 PM. Reason: Changed the initial space removal bit to replace all instances. See below.
        -----------------------------------------

        First Tackle - Fly Fishing and Game Angling

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

        Comment


          #19
          I wonder how this will behave with the weird inner London codes that have extra letters in the middle



          I had a few orders today that were not capitalised perhaps they were cashed orders that were initiated a day or so ago

          I guess the existing customers that have their details in cookies will also stay un-capitalised unless they click on their addresses


          this mod is certainly is going to save some time

          Posted your reward today Norman look out for the postman
          David

          Comment


            #20
            It's much more complex than that. Here's an example regular expression for testing UK postcodes I got when Googling for "UK postcode regular expression".
            Expression: ^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9
            ]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$

            Author: Stuart Wade

            Sample Matches:
            DN3 6GB|||SW42 4RG|||GIR 0AA

            Sample Non-Matches:
            SEW4 5TY|||AA2C 4FG|||AA2 4CV

            Description: Regular expression to match valid UK postcodes. In the UK postal system not all letters are used in all positions (the same with vehicle registration plates) and there are various rules to govern this.

            This regex takes into account those rules. Details of the rules: First half of postcode Valid formats [A-Z][A-Z][0-9][A-Z] [A-Z][A-Z][0-9][0-9] [A-Z][0-9][0-9] [A-Z][A-Z][0-9] [A-Z][A-Z][A-Z] [A-Z][0-9][A-Z] [A-Z][0-9] Exceptions Position - First. Contraint - QVX not used Position - Second. Contraint - IJZ not used except in GIR 0AA Position - Third. Constraint - AEHMNPRTVXY only used Position - Forth. Contraint - ABEHMNPRVWXY Second half of postcode Valid formats [0-9][A-Z][A-Z] Exceptions Position - Second and Third. Contraint - CIKMOV not used
            See http://www.regexlib.com/REDetails.aspx?regexp_id=260 for details.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #21
              The first time I saw the extended London codes I thought it was a mistake

              try multimapping this one

              SW1V 2NP

              Looks wrong but it is valid
              David

              Comment


                #22
                There are scripts that check the validity (as norman shows above) but mine just makes everything upper case and then seperates the inward bit of the postcode (the last three characters) with a space. It will work with all valid postcodes.

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

                First Tackle - Fly Fishing and Game Angling

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

                Comment


                  #23
                  This post is just to let anyone know who's implemented the javascript postcode format function above that I've made a modification so that it correctly removes multiple instances of spaces entered by the customer.

                  Without the changes they would muck up the algorithm.

                  Mike

                  The technical bit:

                  tmpString = string.replace(" ","");

                  will only remove the first occurence of a space, while

                  tmpString = string.replace(/ /g,"");

                  will remove all occurences.
                  -----------------------------------------

                  First Tackle - Fly Fishing and Game Angling

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

                  Comment


                    #24
                    Ok so I have had a whole load more uncapitalised orders through again today from new customers (no existing cookies). Most of them were all lower case.

                    If i go on to my site there is no way I can have uncapitalised lower case

                    I tried a brand new machine in our office that has never been on our site and auto capitalisation was unavoidable.

                    How can the customers avoid the style attribues I am using, ending up all lower case?
                    David

                    Comment


                      #25
                      I'm seeing the same thing.

                      Presumable the the text-transform just affects the presentation of the text, it doesn't actually change the underlying data.

                      Looks like it might be back to javascript.

                      Norman, any comments?

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

                      First Tackle - Fly Fishing and Game Angling

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

                      Comment


                        #26
                        Aaaarrgghh!!!

                        It looks like text-transform only affects appearance. So you may have to use both
                        Code:
                        style="text-transform:uppercase" onchange="this.value=this.value.toUpperCase();"
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #27
                          Also Aaaarrgghh!!!


                          I have re-inserted all the jarva and removed the styles (seemed no need to apply style now)


                          have gone back to the only county not capitalising again

                          Norman. Did you get my letter OK?
                          David

                          Comment


                            #28
                            The idea of leaving the style in is that the client gets to see what's happening as they type.
                            Did you get my letter OK?
                            If it's in the post, then no - not yet.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #29
                              Good old Royal Mail - posted it 3 days ago, First class
                              David

                              Comment


                                #30
                                Just arrived about 2 minutes ago. Many thanks.
                                Norman - www.drillpine.biz
                                Edinburgh, U K / Bitez, Turkey

                                Comment

                                Working...
                                X