Skip to content

Commit 25d8d68

Browse files
author
Igor Escobar
committed
unmask: unsetting maxlength if we set it in the first place
1 parent 9daae58 commit 25d8d68

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/jquery.mask.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@
396396
if (jMask.options.placeholder) {
397397
el.removeAttr('placeholder');
398398
}
399+
if (el.data('mask-maxlength')) {
400+
el.removeAttr('maxlength');
401+
}
399402
p.destroyEvents();
400403
p.val(jMask.getCleanVal());
401404
p.setCaret(caret);
@@ -450,7 +453,7 @@
450453
}
451454

452455
if (maxlength) {
453-
el.attr('maxlength', mask.length);
456+
el.attr('maxlength', mask.length).data('mask-maxlength', true);
454457
}
455458

456459
p.destroyEvents();

test/jquery.mask.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ $(document).ready(function(){
332332
testfield.unmask()
333333
equal(testfield.val(), "1299999999");
334334
equal(testfield.attr('placeholder'), undefined);
335+
equal(testfield.attr('maxlength'), undefined);
335336
});
336337

337338
module('Getting Unmasked Value');

0 commit comments

Comments
 (0)