Announcement

Collapse
No announcement yet.

Capitalise Coupon Code?

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

    #76
    and I had an order from MacEdonia this week too
    Tracey

    Comment


      #77
      That's where the nuts come from isn't it?

      Comment


        #78
        There used to be this code on Graham's website but I can't find it now and having upgraded to 9.0.3 it has wiped this from my actinicextras so I thought I'd post it on here so it's easy to find (for me!)for the future. The code the quotes goes in actinicextras.js as posted earlier in the thread and then the onblur commands are as follows:

        This uses onblur="format(this,'postcode') for formatting the postcode field and onblur="format(this,'upper') for making the town field upper case. Can also be used to good effect in the coupon field. onblur="format(this,'capitals')
        Again these are used as per earlier posts in this thread.


        /***********************************************************************
        *
        * format - formats user input
        *
        * Graham Bradley 2006
        * *
        *
        ************************************************************************/

        function format(el,f){

        var exclude=['Macclesfield','USA'];

        if (!el.value) return false;
        var str=el.value;
        if (f=="cc"){
        var chr=" ";
        str=str.replace(/[^\d]/gi,"");
        str=str.substring(0,4)+chr+str.substring(4,8)+chr+str.substring(8,12)+chr+str.substring(12,str.length);
        }
        else if (f=="upper") str=el.value.toUpperCase();
        else if (f=="postcode" && isNaN(el.value)){
        str=(str.split(" ")).join("");
        str=str.substring(0,(str.length-3))+" "+str.substring((str.length-3),str.length)
        str=str.toUpperCase();
        }
        else if (f=="lower") str=el.value.toLowerCase();
        else if (f=="capitals"){
        str=str.toLowerCase();
        var arr=str.match(/(^.|\s.)/gi);
        for (var i=0;i<arr.length;i++) str=str.replace(arr[i],arr[i].toUpperCase());
        str=str.split(" ");
        for (var i=0;i<str.length;i++){
        index=has(exclude,str[i],1);
        if (index===false){
        var arr=str[i].match(/(-(.)|Mc(.)|Mac(.)|O'(.))/g);
        if (arr){
        for (var j=0;j<arr.length;j++){
        str[i]=str[i].replace(arr[j],arr[j].substring(0,arr[j].length-1)+(arr[j].substring(arr[j].length-1,arr[j].length)).toUpperCase());
        }
        }
        }
        else{
        str[i]=exclude[index];
        }
        }
        str=str.join(" ");
        }
        el.value=str;

        function has(a,v,m){
        for (var i=0;i<a.length;i++){
        if (a[i].toLowerCase()===v.toLowerCase()) return (m ? i : true);
        }
        return false;
        }
        }
        Donna

        Chief bunting supplier to Take That!

        Comment


          #79
          Be good to see this in the KB.

          Comment


            #80
            Somehow I already have this within Actinic, which I did in v8. Somebody, somewhere created a similar modification that required a tag to be added to all of the fields within the checkout. Can't remember who or where I got it from, but it's certainly open source and probably already on this forum. Will have a look for it...

            Comment


              #81
              The second line:

              Code:
              var exclude=['Macclesfield','USA','UAE','Macduff','Macharioch','Machen','Machrie','Machriranish','Machrins','Machynlleth','Machynys','Mackworth','Macmerry','IOW','IOM','Mace','Macey','Mackie','Macartney','Macer','Machaelides','Machell','Machen','Machin','Machola','Machray','Mack','Mackey','Mackiewicz','Mackin','Mackley','Macklin','Mackness','Mackney','Mackrell','Maclure','Macri','Macon','Macedonia'];
              Anybody have anything to add?
              Paul
              Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

              Using V10.2 with Norman's brilliantly simple TABBER.

              Comment


                #82
                I put c/o in the list as in 'care of' not to capitalise i.e. C/o
                David

                Comment


                  #83
                  We only ship to the UK and I want to format all phone numbers regardless into this format: 01234 567 890

                  I know it looks a bit strange on a few STD codes like 0207 0121 024 etc, but we are OK with that

                  Need to take out existing spaces and insert them in the desired places. Have looked on the web but all reference USA style formatting/masking
                  David

                  Comment


                    #84
                    Thank you

                    Credit where credit's due - I have just made good use of this so thank you very much.
                    Kind regards,
                    Phil Benjamin

                    Want to de-stress as you use SellerDeck software?
                    http://www.ursulajamesstore.com

                    Comment


                      #85
                      Can anyone help with the phone number formatting .... Please
                      David

                      Comment


                        #86
                        Something like this would do it:

                        <!--
                        function formatPhoneNumber(string) {
                        var tmpString, first5, middle3, therest, phonenumber;
                        tmpString = string.replace(/ /g,"");
                        first5 = tmpString.substring(0,5);
                        middle3 = tmpString.substring(5,8);
                        therest = tmpString.substring(8);
                        phonenumber = first5 + " " + middle3 + " " + therest;
                        return phonenumber;
                        }
                        // -->
                        Not tested, but it's fairly simple code.

                        Mike

                        Edit: Made a couple of changes to put the spaces where wanted.
                        -----------------------------------------

                        First Tackle - Fly Fishing and Game Angling

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

                        Comment


                          #87
                          Excellent thread, couple of odd things, if anyone could help, much appreciated.

                          I have added
                          onblur="format(this, 'capitals')"
                          at each location as required but InvoiceAddress4 does not seam to work.

                          I have shipping instruction which go on the address label, I thought if they were in capitals it would make the postie job easier and possible they would read them! However, I applied 'upper' to that field and now I have noticed that it strips out the spaces, reformats it in the postcode format.

                          How do I apply this capitalise formatting on its own, I did try Can I automatically capitalise customer input from KB thread but it did not work.

                          Any thoughts would be appreciated.

                          M
                          Mash

                          Comment


                            #88
                            Although it says 'provided by a Forum Member', the hack given in the KB & the AUG is not quite the same as the one on this thread, you need to use one, or the other. This one is better, but Kermy's website no longer exists and the thread has lost a bit of focus in spite of Donna's effort. Even so the following is not definitive.

                            Stage 1. Copy and paste all of the following, and add this code to the very end of actinicextras.js:

                            Code:
                            /***********************************************************************
                            *
                            * format - formats user input in Actinic Checkout Pages
                            *
                            * written by Graham Bradley 2006 with adjustments from various subsequent users
                            * *
                            *
                            ************************************************************************/
                            
                            function format(el,f){
                            
                            var exclude=['Macclesfield','USA','UAE','Macduff','Macharioch','Machen','Machrie','Machriranish','Machrins','Machynlleth','Machynys','Mackworth','Macmerry','IOW','IOM','Mace','Macey','Mackie','Macartney','Macer','Machaelides','Machell','Machen','Machin','Machola','Machray','Mack','Mackey','Mackiewicz','Mackin','Mackley','Macklin','Mackness','Mackney','Mackrell','Maclure','Macri','Macon','Macedonia'];
                            
                            if (!el.value) return false;
                            var str=el.value;
                            if (f=="cc"){
                            var chr=" ";
                            str=str.replace(/[^\d]/gi,"");
                            str=str.substring(0,4)+chr+str.substring(4,8)+chr+str.substring(8,12)+chr+str.substring(12,str.length);
                            }
                            else if (f=="upper") str=el.value.toUpperCase();
                            else if (f=="postcode" && isNaN(el.value)){
                            str=(str.split(" ")).join("");
                            str=str.substring(0,(str.length-3))+" "+str.substring((str.length-3),str.length)
                            str=str.toUpperCase();
                            }
                            else if (f=="lower") str=el.value.toLowerCase();
                            else if (f=="capitals"){
                            str=str.toLowerCase();
                            var arr=str.match(/(^.|\s.)/gi);
                            for (var i=0;i<arr.length;i++) str=str.replace(arr[i],arr[i].toUpperCase());
                            str=str.split(" ");
                            for (var i=0;i<str.length;i++){
                            index=has(exclude,str[i],1);
                            if (index===false){
                            var arr=str[i].match(/(-(.)|Mc(.)|Mac(.)|O'(.))/g);
                            if (arr){
                            for (var j=0;j<arr.length;j++){
                            str[i]=str[i].replace(arr[j],arr[j].substring(0,arr[j].length-1)+(arr[j].substring(arr[j].length-1,arr[j].length)).toUpperCase());
                            }
                            }
                            }
                            else{
                            str[i]=exclude[index];
                            }
                            }
                            str=str.join(" ");
                            }
                            el.value=str;
                            
                            function has(a,v,m){
                            for (var i=0;i<a.length;i++){
                            if (a[i].toLowerCase()===v.toLowerCase()) return (m ? i : true);
                            }
                            return false;
                            }
                            }
                            Stage 2. In the Design Tab, use the dropdown box to select 'Checkout Page 0' then navigate to the Input Fields by highlighting them in Page View then moving to Layout Code pane.

                            Insert the following code just before '>' or '/>' (example below)

                            (a) For First Name, Last Name, Name and the various Address fields* add:

                            Code:
                            onblur="format(this, 'capitals')"
                            this will Capitalise (capitalize) the first letter of each word, excepting words such as McDonald, MacDonald yet ignoring words such as MacClesfield.

                            (b) For the Postcode field use:

                            Code:
                            onblur="format(this, 'postcode')"
                            this will put the postcode into capital letters with a space in between the inbound and outbound parts. This also works where you are using PostCodeAnywhere, not that it matters.

                            (c)* (Optional) For AddressLine4 you can use

                            Code:
                            onblur="format(this, 'upper')"
                            this will put the town name all in capitals, useful for postage labels. This can also be applied to the Coupon Code field where you issue a coupon in capitals ('MAR2011') but the customer types in 'mar2011'.

                            EXAMPLE: change the line:

                            Code:
                            <input type="text" id="idINVOICEFIRSTNAME" name="INVOICEFIRSTNAME" size="30" maxlength="40" value="<actinic:variable name="InvoiceFirstNameOnline" selectable="false" />" tabindex="NETQUOTEVAR:TABINDEXINVOICEFIRSTNAME" >
                            to be

                            Code:
                            <input type="text" id="idINVOICEFIRSTNAME" name="INVOICEFIRSTNAME" size="30" maxlength="40" value="<actinic:variable name="InvoiceFirstNameOnline" selectable="false" />" tabindex="NETQUOTEVAR:TABINDEXINVOICEFIRSTNAME" onblur="format(this,'capitals')" >


                            This explanation DOES NOT include Mike's 'phone number' hack and the code no longer needs onblur="format(this, 'cc')" to put Credit Card numbers into groups of four as it should no longer be required - but I don't know how to take it out. Also available is onblur="format(this, 'lower')" though I can't think why you would want it.
                            ____________
                            Paul
                            Paul
                            Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                            Using V10.2 with Norman's brilliantly simple TABBER.

                            Comment


                              #89
                              'onchange' NOT 'onblur'

                              To ensure compatability with Firefox & Chrome browsers, substitute 'onblur' with 'onchange'.

                              onchange="format(this, 'upper')" - to change the field to upper case
                              onchange="format(this, 'lower')" - to change the field to lower case
                              onchange="format(this, 'capitals')" - to change the field to capital case (ie first letters of each word in capitals)
                              onchange="format(this, 'postcode')" - to format the postcode field
                              Paul
                              Flower-Stands.co.uk - the UK's largest online supplier of Fresh Flower Merchandising Stands

                              Using V10.2 with Norman's brilliantly simple TABBER.

                              Comment


                                #90
                                It's virtually impossible to correctly automate the capitalisation of names and places. Apart from anything else, the same prefix and even the same surname is often capitalised differently by different families. Eg 'Van der', 'Van Der' and 'van der' may all be considered valid. There are no rules for this, it's partly according to the whim of each family.

                                Which is worse? Passing over the capitalisation of someone who couldn't even be bothered to type their own name properly? Or taking the name of someone who did type it in correctly, and changing it to something that's just plain wrong?
                                Bruce Townsend
                                Ecommerce Product Manager
                                Sellerdeck Ecommerce Solutions

                                Comment

                                Working...
                                X