Get IMask Value

1.4k Views Asked by At

I would like to retrieve the 'value' from the below using JavaScript:

InputMask {el: HTMLMaskElement, masked: MaskedPattern, _listeners: {…}, _value: '', _unmaskedValue: '', …} alignCursor: ƒ () alignCursorFriendly: ƒ () el: HTMLMaskElement {input: input#l3-19_0-Input_Value.form-control.input_js.OSFillParent, _handlers: {…}} masked: MaskedPattern {value: '', lazy: true, placeholderChar: '', mask: 'aaaa0000000', definitions: {…}, …} _changingCursorPos: 11 _listeners: {} _onChange: ƒ () _onDrop: ƒ () _onInput: ƒ () _saveSelection: ƒ () _selection: {start: 11, end: 11} _unmaskedValue: "aaaa1234567" _value: "aaaa1234567" cursorPos: (...) mask: (...) selectionStart: (...) typedValue: (...) unmaskedValue: (...) value: (...) [[Prototype]]: Object

This is the logged value of:

var mask = new IMask(element, maskOptions);

I have tried:

console.log(mask.value) and console.log(mask.unmaskedValue) but neither has worked.

1

There are 1 best solutions below

0
On

Use mask.unmaskedValue

var masked = IMask(element, {
  mask: /^\d+$/
});

console.log(masked.typedValue);