## The Tax ID Element The [Tax ID Element](/elements/tax-id-element.md) is an embeddable component for collecting customer tax ID information for tax reporting and compliance purposes. ## Create a Tax ID Element This method creates an instance of the Tax ID Element. > This feature requires the `elements_tax_id_1` beta. To use it, pass `betas: ['elements_tax_id_1']` when initializing Stripe.js. **Syntax:** `elements.create(...)` - `type` ('taxId') **required** The type of Element being created, which is `taxId` in this case. - `options` (object) Tax ID Element initialization options. - `visibility` ('always' | 'never' | 'auto') By default, the Tax ID Element displays when the user is in a country that supports tax ID collection. Specify `always` to display the element regardless of the user's country. Specify `never` to hide the element completely. - `fields` (object) By default, the Tax ID Element collects all tax ID information. If it's not necessary for you to collect all fields, you can disable Tax ID Element collection of certain fields with the `fields` option. - `businessName` ('always' | 'never' | 'auto') Specify `always` to collect the business name. Specify `never` to not collect the business name. Default is `auto`. - `validation` (object) By default, the Tax ID Element will enforce preset validation for each field. You can customize the settings by using this option. - `businessName` (object) - `required` ('always' | 'never' | 'auto') Specify `always` to make business name a required field. Specify `never` to make business name an optional field. Default is `auto`. - `taxId` (object) - `required` ('always' | 'never' | 'auto') Specify `always` to make tax ID a required field. Specify `never` to make tax ID an optional field. Default is `auto`. ### Create a Tax ID Element ```js var taxIdElement = elements.create('taxId', { visibility: 'auto', }); ``` ```es_next const taxIdElement = elements.create('taxId', { visibility: 'auto', }); ``` ## Retrieve a Tax ID Element This method retrieves a previously created Tax ID Element. `elements.getElement('taxId')` returns one of the following: * An instance of a Tax ID Element. * `null`, when no Tax ID Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('taxId') **required** The type of Element being retrieved, which is `taxId` in this case. ### Retrieve a Tax ID Element ```js var taxIdElement = elements.getElement('taxId'); ``` ```es_next const taxIdElement = elements.getElement('taxId'); ``` ## Get value from a Tax ID Element Validates and retrieves form values from a Tax ID Element. If there are any input validation errors, the errors are displayed by their associated fields. `taxIdElement.getValue()` returns a promise. This promise returns an object with the following: * `complete`, `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It doesn't indicate whether a customer is done with their input. Rather, it only indicates that the Element contains a potentially complete, well-formed value. In many cases, the customer can still add further input. * `empty`, `true` if both the business name and tax ID fields are empty. * `visible`, `true` if the Tax ID Element is visible based on the `visibility` option and country. * `value`, an object containing the current tax ID information. The `businessName` property may be `null` if not configured to be collected. **Syntax:** `element.getValue(...)` ### Get value from a Tax ID Element ```js var taxIdElement = elements.getElement('taxId'); taxIdElement.getValue() .then(function(result) { if (result.complete) { // Allow user to proceed to the next step // Optionally, use value to store the tax ID details } }) ``` ```es_next const taxIdElement = elements.getElement('taxId'); const {complete, value} = await taxIdElement.getValue(); if (complete) { // Allow user to proceed to the next step // Optionally store the tax ID details with value } ```