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
error
Listen 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 change
balanceElement.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
complete
Listen 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)
}
});