Session onEmptinessChange

onEmptinessChange Callback

The onEmptinessChange( ) callback method is invoked when the hosted field becomes empty or is no longer empty.


Usage Copied to clipboard

PaymentSession.onEmptinessChange([HostedFieldsRole], function(selector, result), [scope])


Example Copied to clipboard

PaymentSession.onEmptinessChange(["card.number", "card.nameOnCard"], function(selector, result) {
    //handle change event
    if (result.isEmpty) {
        // field has empty value
        console.log("Element with selector " + selector + " has changed it's emptiness status to empty");
    } else if (!result.isEmpty) {
        // field has non-empty value
        console.log("Element with selector " + selector + " has changed it's emptiness status to non-empty");
    }
});

Example for emptiness change result object Copied to clipboard

{
    "isEmpty":boolean
}

Arguments Copied to clipboard

HostedFieldsRole Copied to clipboard Array REQUIRED

An array of field roles for the hosted fields where the event occurred. Valid array of field roles:

card.nameOnCard
card.number
card.expiryMonth
card.expiryYear
card.securityCode
giftCard.number
giftCard.pin
ach.bankAccountNumber
ach.bankAccountNumberConfirmation
ach.bankAccountHolder
ach.routingNumber
directDebitCanada.bankAccountNumberConfirmation
directDebitCanada.bankAccountHolder
directDebitCanada.bankAccountNumber
directDebitCanada.financialInstitutionNumber
directDebitCanada.transitNumber
callbackFunction Copied to clipboard Function

The callback function invoked with selector and the result when an event is triggered.

selector Copied to clipboard String

Identifier of the HTML element that the merchant has changed the state of emptiness (ex: "#card-number").

result Copied to clipboard Object

Result object which sent as an argument to the function.

isEmpty Copied to clipboard Number

It defines whether that particular field is empty or not.

scope Copied to clipboard String

The optional named instance of a card payment data set within a session. See Multiple Hosted Sessions for more information.


Return Value Copied to clipboard

None