I use jQuery Masked Input plugin to set all input elements with the data mask attribute defined for the attribute mask value:
Given this html:
<input type='text' id="a" data-mask='999?999' /> <input type='text' id="b" data-mask='999' />
And this script:
$("input[data-mask]").each(function() { var maskValue = $(this).data('mask'); console.log($(this).attr('id') + ": " + maskValue);
The second iteration is thrown: "Uncaught TypeError: undefined is not a function" on this line, because "split" is not defined.
firstNonMaskPos = null, $.each(mask.split(""), function(i, c) {
This code, however, works very well; masks are installed without problems.
$('#a').mask('999?999'); $('#b').mask('999');
Can anyone shed light on this strange behavior?
JsFiddle demo here
source share