1. Home
  2. Interswitch lending Service
  3. Value Financing
  4. Tokenization Using Hosted Fields
  5. Tokenization Event

Tokenization Event

There are available events emitted by the hosted field instance that you can subscribe to. This can be done on the hostedField instance.

These events include:

Name
Event Description
focus This event is emitted when a field gains focus
blur This is emitted when a field loses focus
validityChange This is emitted when the validity of a field changes
empty This is emitted when the field becomes empty

 

Register the events using the on method on the hostedFieldInstance returned.

See below an example using the focus and blur event:

Events
function findLabel(field)
{
    return $('.hosted-field--label[for="' field.container.id + '"]');
}
hostedFieldInstance.on('focus'function (event) {
   var field = event.fields[event.emittedBy];
   findLabel(field).addClass('label-float').removeClass('filled');
});
                        
hostedFieldInstance.on('blur'function (event) {
   var field = event.fields[event.emittedBy];
   var label = findLabel(field);
   if (field.isEmpty) {
      label.removeClass('label-float');
    else if (field.isValid) {
      label.addClass('filled');
    else {
      label.addClass('invalid');
    }
});

 

Was this article helpful to you? Yes No

How can we help?