3

So while LiveAddress works great for US address we have to support international addresses as well. I already have a country dropdown that's enabling LiveAddress only when the person chooses the US. However I need to now "disable" LiveAddress anytime someone picks a country other than the US.

$(".chosen-select").on("change", function (e) {
    if (e.added.id == "USA") {
        showUSStates();
        $.LiveAddress("<My Key>");
    } else if (e.added.id == "CAN") {
        showCANProvinces();
        //Disable Live Address here?
    } else {
        //Disable Live Address here?
        $("label[for=State]").html("Province");
        $("#State").hide()
        $("#Province").show()
        $("#State").empty();
    }
});

Thanks!

Solution:

So it's not documented in their web pages but I read the unminimized js file and discovered that if you map the country field they library AUTOMATICALLY turns itself off once someone chooses a country other than US.

   $(document).ready(function () {
        showUSStates();
        $.LiveAddress({
            key: "<My Key>",
            addresses: [{ 
                id: 'billing', 
                street: '#Address1', 
                city: '#City', 
                state: '#State', 
                zipcode: '#PostalCode', 
                **country: '#Country'** }],
            autoVerify: false
        });
    });

Great feature, just unfortunate that the online documentation doesn't detail this NOR did the online chat team know of this feature.

CodingSamurai
  • 101
  • 1
  • 7

1 Answers1

1

http://smartystreets.com/kb/liveaddress-api/plugin/advanced lists autoVerify(...)

autoVerify([newSetting]) ver 2.4.3+
Pass in a truthy value to turn on auto-verify, or a falsey value to turn it off. Don't pass in anything to simply return the current autoVerify setting.

I'm not sure if that's what you're looking for?

EDIT deactivate(...) and activate(...) may be more useful for you?

DimeCadmium
  • 314
  • 2
  • 9
  • So the autoVerify field is just specifying whether the address found on lookup is then verified with the USPS verification before submit automatically (once user pauses input). The activate & deactivate specify if the particular set of address fields will be verified upon submit (default is yes). So appreciate the effort but not quite what I was looking for. – CodingSamurai Dec 21 '13 at 00:54
  • Ah! I've never actually *used* LiveAddress, but good to know you solved it eventually! – DimeCadmium Dec 21 '13 at 06:20