onEmptinessChange Callback

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

Usage

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

Example

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");
    }
});

Arguments

<HostedFieldsRole> Array COMPULSORY

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.bankAccountHolder', 'ach.routingNumber']

<callbackFunction> Function COMPULSORY

The callback function invoked when the event is triggered.

scope String OPTIONAL

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

Return Value

None

Copyright © 2023 MasterCard