The Form
The checkout form is driven by a single enhancer activated by data-next-checkout on a <form>. It finds your fields, validates them, populates the country and state dropdowns, manages a separate billing address, and submits the order.
How Fields Are Found
The SDK does not rely on input name or id. It locates each field by attribute:
data-next-checkout-field="<name>"— current conventionos-checkout-field="<name>"— legacy convention (still supported)
Both work; prefer data-next-checkout-field in new pages. The value is the standard field name, which the SDK maps to the order API for you.
Standard field names
| Field name | Purpose | Element |
|---|---|---|
email | Email address | input[type=email] |
fname | First name | input |
lname | Last name | input |
phone | Phone number | input[type=tel] |
address1 | Street address | input |
address2 | Apartment / suite (optional) | input |
city | City | input |
province | State / province | select |
postal | Postal / ZIP code | input |
country | Country | select |
Card field names are covered in Payment.
address2 is the only address field that is always optional. province is required only for countries whose configuration marks a state as required.
Validation
Validation runs on submit and on field blur. If a field is invalid, the SDK marks it and shows a message; on submit it focuses and scrolls to the first error.
| Field | Rule |
|---|---|
email | Valid email format |
fname, lname | Letters, spaces, hyphens, and apostrophes |
phone | International format via intl-tel-input; falls back to a minimum digit count |
city | Letters only, minimum 2 characters |
postal | Country-specific format (e.g. US ZIP 12345 or 12345-6789) |
province | Required when the selected country requires a state |
country | Must be one of the campaign's available shipping countries |
When a field fails, the SDK adds the has-error / next-error-field classes to it and writes the message into an error container (see Error display). A valid field gets no-error.
HTML5 native validation is bypassed — the form uses the SDK's validator instead, so the browser's built-in "Please fill out this field" bubbles will not appear.
Error display
The SDK writes each field's error message into a container it finds near the field. You can provide one explicitly:
<input data-next-checkout-field="email" type="email" />
<div data-next-error="email"></div>os-checkout-error="email" is also accepted. If no container is found, the SDK creates an inline error label next to the field.
Country & State
The country dropdown is filled from the campaign's available shipping countries. The province dropdown is populated from the selected country's states. Changing the country:
- Refreshes the
provinceoptions for that country - Re-labels the state field (e.g. "State", "Province", "Region")
- Re-labels and re-validates the postal field (e.g. "ZIP", "Postcode")
You can leave both <select> elements empty in your HTML — the SDK fills them.
Progressive Address Fields
To keep the form visually short, the city / state / postal block can stay hidden until the visitor starts a street address. Wrap those fields in a location container:
<div data-next-component="location">
<input data-next-checkout-field="city" />
<select data-next-checkout-field="province"></select>
<input data-next-checkout-field="postal" />
</div>The container is hidden (next-location-hidden) until address1 receives a value, then revealed. The matching billing container is data-next-component="billing-location".
Separate Billing Address
By default the billing address equals the shipping address. To let customers enter a different one, add a billing toggle and a billing form container:
<!-- toggle: checked = same as shipping -->
<input type="checkbox" name="use_shipping_address" checked />
<!-- shown only when billing differs from shipping -->
<div data-next-component="billing-form">
<input data-next-checkout-field="billing-fname" />
<input data-next-checkout-field="billing-lname" />
<input data-next-checkout-field="billing-address1" />
<input data-next-checkout-field="billing-city" />
<select data-next-checkout-field="billing-province"></select>
<input data-next-checkout-field="billing-postal" />
<select data-next-checkout-field="billing-country"></select>
</div>Billing fields use the same standard names prefixed with billing-. When the toggle says billing is the same as shipping, the billing form is hidden and only shipping is validated. When it differs, the billing form expands and its fields are validated too.
The container can also be marked with data-next-component="different-billing-address" (or the legacy os-checkout-element="different-billing-address") to control its visibility.
Component Containers
These optional containers let the SDK manage sections of the form. Each accepts the data-next-component form (preferred) or the legacy os-checkout-component / os-checkout-element form.
| Container | Purpose |
|---|---|
data-next-component="shipping-form" | Shipping fields wrapper |
data-next-component="billing-form" | Billing fields wrapper (animated open/close) |
data-next-component="different-billing-address" | Wrapper that toggles billing visibility |
data-next-component="location" | City / state / postal, revealed after address1 |
data-next-component="billing-location" | Billing city / state / postal |
data-next-component="shipping-field-row" | A single field row |
Next Steps
- Card fields and payment methods: Payment
- Speed up address entry: Address Autocomplete
- All field names and attributes: Reference → Attributes
- State classes the form toggles: Reference → CSS