> For the complete documentation index, see [llms.txt](https://docs.verygoodsecurity.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verygoodsecurity.com/vault/developer-tools/vgs-collect/js/card-attribute-lookup-during-card-entry.md).

# Card Attribute Lookup During Card Entry

VGS Collect can provide your front-end insights into the card details. VGS will perform the card attribute lookup after the 11th digit is entered into the Card Number Field. Details on which attributes a card can get access to can be found [here](https://docs.verygoodsecurity.com/cmp/products-and-services/card-attributes).

## Step 1: Create Form and Select Attributes

In the VGS Dashboard, create a Collect Form and select all the attributes you wish to be included in the attribute lookup.

<figure><img src="https://2096104711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUreALQAfVnRMQEz110rC%2Fuploads%2FPlgGkek2YDTR43pdFQvg%2Fimage.png?alt=media&amp;token=43862b8f-5e4e-4247-aba1-5410085e4d3f" alt=""><figcaption></figcaption></figure>

## Step 2: Implement Card Attribute Lookup Hooks on Collect Form

```javascript
const form = await VGSCollect.session({
  vaultId: 'tntYOUR_TENANT_ID',
  env: 'sandbox',
  formId: 'default',
  stateCallback: stateCallback.bind(state),
  authHandler: getVGSAuthToken,
  // error handler if config doesn't load
  onErrorCallback: (error) => {
    console.log(error);
  },
});

// Getting card attributes (success handler)
form.on('getCardAttributesSuccess', (lookup) => {
  console.log('getCardAttributesSuccess', lookup)
});

// Getting card attributes (error handler)
form.on('getCardAttributesError', (errors) => {
  console.log(errors)
});

// Fields
form.cardholderNameField('#cc-name .fake-input', {});
form.cardNumberField('#cc-number .fake-input', {});
form.cardExpirationDateField('#cc-exp-date .fake-input', {});
form.cardCVCField('#cc-cvc .fake-input', {});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/vgs-collect/js/card-attribute-lookup-during-card-entry.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
