Emitted when an EBT Element’s value changes.
The change EBT Element event object contains an additional complete field. The complete value is a boolean that indicates whether the EBT element contains a valid input.
{
type: 'change',
usecase: 'collect_pin',
complete: true,
error: null
}Listen for error
errorListen for an error value on the change event object to display input validation errors to the user.
Example
Display a message if there’s an event.error on change
event.error on changebalanceElement.on('change', (event) => {
const explainErrorSpan = document.getElementById('explain-error')
if (event.error) {
// show validation error to customer
explainErrorSpan.textContent = event.error.message
} else {
// hide validation error
explainErrorSpan.textContent = ''
}
})Listen for complete
completeListen for the complete value on the change event object to change the UI when an input value is ready to submit.
Example
Enable a submit button if event.complete on change is true
event.complete on change is truebalanceElement.on('change', (event) => {
const submitBalanceCheckBtn = document.getElementById('submit-balance-btn')
if (event.complete) {
// enable submit button
setDisabled(false)
}
});