Skip to Content
Docs

Validate form fields

Check the current state of the Universal checkout form fields without submitting the form.

The checkout.validate() method checks the current state of the Universal checkout form fields without submitting the form. Call it before checkout.submit() when you submit the form with your own button.

const result = await checkout.validate()

Parameters

None.

Returns

FieldTypeDescription
validbooleantrue if all required fields pass validation.
invalidFieldsstring[]Names of fields that failed validation. Empty when valid is true.

Example

const { valid, invalidFields } = await checkout.validate()

if (valid) {
  await checkout.submit()
} else {
  console.log('Fix these fields:', invalidFields)
}
Was this page helpful?