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 |
Method Summary
Public Methods | ||
public |
destroy() Unwrap the input elements and remove attached listeners |
|
public |
refresh() 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:
Name | Type | Attribute | Description |
options | Object |
|
The input options. |
options.elements | HTMLElement | String |
|
The class name or the node to use |
options.document | HTMLDocument |
|
Document instance to use |
options.cssClassError | String |
|
A css class to attach to the input when it is invalid |
options.cssClassSuccess | String |
|
A css class to attach to the input when it is valid after the user interaction |
options.onUpdate | Function |
|
A callback to be called on the new masked value is set |
options.onInvalid | Function |
|
A callback to be called on the input or the mask is invalid |