[ Web Proxy ]
URL:
Viewing: https://developer.squareup.com/reference/sdks/web/payments/objects/CardInputEventState [Back]  [Original]

CardInputEventState Object - Square Web Payments SDK Reference

#
CardInputEventState

The state of an input field at the time a card input event is triggered

Properties

#
hasErrorClass boolean

An error style class is applied to the input field due to an input error

#
hasFocusClass boolean

The input field has been selected

#
isCompletelyValid boolean

The SDK has validated the input field contents

#
isEmpty boolean

The input field is empty

#
isPotentiallyValid boolean

The input value is not empty and is being validated

cardInputEventState.js
JS
JavaScript
Copy

card.addEventListener("cardBrandChanged",  async (cardInputEvent) => {

  const currentInputEventState = cardInputEvent.currentState;

  const previousInputEventState = cardInputEvent.previousState;

  const eventMessage = `Valid input? ${currentInputEventState.isCompletelyValid}

  Was field empty? ${previousInputEventState.isEmpty}`

  alert(eventMessage);

});

Web Proxy Viewer  |  New URL  |  Original Page