Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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])
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down