Using the JavaScript CheckIt Function in ShopSite

Forum Forums Tutorials Using the JavaScript CheckIt Function in ShopSite

This topic contains 0 replies, has 1 voice, and was last updated by  Anonymous 19 years, 7 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #48512

    Anonymous
    Participant

    In a previous tutorial, we introduced the topic of using JavaScript in ShopSite to achieve a number of goals. The focus of this tutorial is to show you how to use JavaScript to enhance the CheckIt function in ShopSite Pro. This function verifies that required fields have valid content in them, and runs when the user presses the ‘submit’ button.

    Using JavaScript in this CheckIt field, which for the checkout screen is located in your backoffice under Commerce Setup -> Order System -> Checkout, can force your users to make valid entries in your required fields. For example, if you do not ship to P.O. boxes, and want to be sure your buyers do not enter in a P.O. Box into the shipping address field, you could use the following code:

     

    var shippingaddress=""; 
     var billingaddress=""; 
     billingaddress = document.billing.Address.value; 
     shippingaddress = document.billing.ShipAddress.value; 
     if (shippingaddress.match(/PO Box/i)) { 
       error += "We cannot ship to a PO Box\n"; 
     } 
     if (shippingaddress.match(/P.O. Box/i)) { 
       error += "We cannot ship to a PO Box\n"; 
     } 
     if ((document.billing.usebilling != undefined) &&  
             (document.billing.usebilling.checked == true)) { 
     if (billingaddress.match(/PO Box/i)) { 
       error += "We cannot ship to a PO Box\n"; 
     } 
     if (billingaddress.match(/P.O. Box/i)) { 
       error += "We cannot ship to a PO Box\n"; 
     } 
     } 
    

     

    Note that the CheckIt function is not restricted to the checkout screen, as it can also run on the shopping cart screen (Commerce Setup -> Order System -> Shopping Cart). In order to see a list of shopping cart JavaScript variables, reference:

    http://www.shopsite.com/help/8.0/en-US/sc/pro/cart.variables.html

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.