Home Reference Source
public class | source

TextInput

The TextInput will wrap text inputs and apply the given bbj string mask

Options

Options can be passed via data attributes . For data attributes, append the option name to data-, as in data-mask

Option Default Description
mask The bbj string mask @see BBj String Masks


Example :

 <input class="bbj-text-masked" name="test" id="test" value="ed23" data-mask="AA-00">

 <script>
   document.addEventListener('DOMContentLoaded', function (e) {
     new Basis.InputMasking.TextInput({
        onUpdate: (maskedValue , rawValue , input) => {
           // do something
        },
        onInvalid: (err , input) => {
           // do something
        }
     })
   })
 </script>

Constructor Summary

Public Constructor
public

constructor(options: Object)

Construct new TextInput

Member Summary

Public Members
public

options: {...undefined: Object, ...options: Object}

Method Summary

Public Methods
public

Unwrap the input elements and remove attached listeners

public

Initialize the component and wrap the input elements for masking in case they are not wrapped yet

Public Constructors

public constructor(options: Object) source

Construct new TextInput

Params:

NameTypeAttributeDescription
options Object
  • nullable: true

The input options.

options.elements HTMLElement | String
  • optional
  • default: ".bbj-text-masked"

The class name or the node to use

options.document HTMLDocument
  • optional
  • default: document

Document instance to use

options.cssClassError String
  • optional
  • default: "bbj-mask-error"

A css class to attach to the input when it is invalid

options.cssClassSuccess String
  • optional
  • default: "bbj-mask-success"

A css class to attach to the input when it is valid after the user interaction

options.onUpdate Function
  • optional
  • default: null

A callback to be called on the new masked value is set

options.onInvalid Function
  • optional
  • default: null

A callback to be called on the input or the mask is invalid

Public Members

public options: {...undefined: Object, ...options: Object} source

Public Methods

public destroy() source

Unwrap the input elements and remove attached listeners

public refresh() source

Initialize the component and wrap the input elements for masking in case they are not wrapped yet