Announcement

Collapse
No announcement yet.

Can I automatically capitalise customer input?

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

    Can I automatically capitalise customer input?

    Customers will not always enter their name and address information with capital letters online. This then means you will often have to manually edit the details once you have receive the order into SellerDeck.

    This is a JavaScript function that will apply correct capitalisation to the details customers enter in your checkout as they type them.

    First of all, you need to go to the 'Design' tab and select 'Checkout Page 1' from the 'Select Page Type' drop down list. Then locate the overall page layout and insert the following function into the <head> section, just above the </head> tag.

    HTML Code:
    <script language=JavaScript>
    <!--
    function capitalizeWords(string) {
    var tmpStr, tmpChar, preString, postString, strlen;
    tmpStr = string.toLowerCase();
    stringLen = tmpStr.length;
    if (stringLen > 0)
    {
    for (i = 0; i < stringLen; i++)
    {
    if (i == 0)
    {
    tmpChar = tmpStr.substring(0,1).toUpperCase();
    postString = tmpStr.substring(1,stringLen);
    tmpStr = tmpChar + postString;
    }
    else
    {
    tmpChar = tmpStr.substring(i,i+1);
    if (tmpChar == " " && i < (stringLen-1))
    {
    tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
    preString = tmpStr.substring(0,i+1);
    postString = tmpStr.substring(i+2,stringLen);
    tmpStr = preString + tmpChar + postString;
    }
    }
    }
    }
    return tmpStr;
    }
    // -->
    </script>
    Once you have done that, you can click on any fields in the page that you want capitalised, and just add in the call to the function. For example, replace:

    HTML Code:
    <input type="text" name="INVOICENAME" size="20" maxlength="40" value="<Actinic:Variable Name="InvoiceName"/>" />
    with

    HTML Code:
    <input type="text" name="INVOICENAME" size="20" maxlength="40" value="<Actinic:Variable Name="InvoiceName"/>" onchange="this.value = capitalizeWords(this.value)" />
    i.e. add the following into any <input> tag where you want the contents capitalised:

    HTML Code:
    onchange="this.value = capitalizeWords(this.value)"
    Disclaimer: This code was provided by an SellerDeck user via the SellerDeck Community (http://community.sellerdeck.com/) and so can't be supported by the SellerDeck Technical Support team.
Working...
X