diff --git a/lib/index.js b/lib/index.js index 3c7c31f..96d158e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -177,7 +177,7 @@ Pattern.prototype.isEditableIndex = function isEditableIndex(index) { * @return {boolean} */ Pattern.prototype.isValidAtIndex = function isValidAtIndex(char, index) { - return this.formatCharacters[this.pattern[index]].validate(char) + return this.isEditableIndex(index) && this.formatCharacters[this.pattern[index]].validate(char) } Pattern.prototype.transform = function transform(char, index) { @@ -498,7 +498,7 @@ InputMask.prototype.getValue = function getValue() { InputMask.prototype.getRawValue = function getRawValue() { var rawValue = [] for (var i = 0; i < this.value.length; i++) { - if (this.pattern._editableIndices[i] === true) { + if (this.pattern.isValidAtIndex(this.value[i], i)) { rawValue.push(this.value[i]) } } diff --git a/test/index.js b/test/index.js index 34f473e..2fbf424 100644 --- a/test/index.js +++ b/test/index.js @@ -27,6 +27,13 @@ test('README example', function(t) { t.end() }) +test('getRawValue', function(t) { + t.plan(1) + var mask = new InputMask({pattern: '1111 1111', value: '98781'}) + + t.equal(mask.getRawValue(), '98781', 'Current value without non-editable pattern characters') +}) + test('formatValueToPattern', function(t) { t.plan(7)