> ## Documentation Index
> Fetch the complete documentation index at: https://developer.tazapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Change Event

> The change event is triggered when the value of the embed changes. The payload of this event contains keys specific to the embed you are using

## Method Parameters

1. `event` - mandatory\
   The name of the event, in this case `change`
2. `handler` - mandatory\
   handler(event) => void is a callback function that a merchant will provide that will be called when the event is fired. When called it will be passed an event object with the following properties:

   | Field | Sub-field | | Type | Description |
   | :- | :- | :- | :- | :- |
   | embedType | | | string | The type of embed that emitted this event. In this case card |
   | empty | | | boolean | true if the embed is empty |
   | complete | | | boolean | true if the embed is well-formed and potentially complete. That is the merchant can use this to enable their pay button |
   | error | | | json | Any error that we surface to the customer while they are typing |
   | value | | | json | |
   | | cardholder\_name | | string | Cardholder name entered by the customer on the embed |
   | | expiry | | json | Card Expiry Details |
   | | | month | integer | Number representing the card’s expiration month |
   | | | year | integer | Four-digit number representing the card’s expiration year. |
   | | last4 | | string | The last 4 digits of the card |
   | | first6 | | string | The first 6 digits of the card |
   | scheme | | | enum | Card scheme - visa, mastercard, american\_express |

## Handling a card embed change event

```javascript Javascript theme={null}
cardEmbed.on('change', function(event) {
  if (event.complete) {
    // enable payment button
  } else if (event.error) {
    // show validation to customer
  }
});
```

## Handler event object

```json Object theme={null}
{
  complete: false,
  brand: 'visa',
  embedType: 'card',
  empty: false,
  error: {
    cardNumber: "Enter the card number",
    expiry: "Enter valid expiry date",
    cvv: "",
    name: ""
  },
  value: { cardholder_name: "" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.