I've been using this plugin for quite some time:
And this week I made a change in the way I use it, I started calling it like this:
The Caller for input:
var mainValidator = function () {
var fieldValidation = function () {
$(document).on('keyup focus', '.input-field', function () {
var $this = $(this);
var mask = $this.data('input-mask');
var type = $this.data('input-type');
if ($.isEmptyObject(mask)) {
console.log('no mask');
} else {
makeMask(mask, $this);
}
if ($.isEmptyObject(mask)) {
console.log('no type');
} else {
var caller = {
function: 'make_validation',
model: $this.data('input-type')
};
$.ajax({
type: "POST",
url: "callers.php",
data: {caller},
dataType: 'json',
success: function (data)
{
alert(data);
}
});
}
});
};
return {
init: function () {
fieldValidation();
}
};
}();
jQuery(document).ready(function () {
mainValidator.init();
});
Here is an example of the mask application:
var makeMask = function (mask,$this) {
//E-mail
if (mask === 'mail') {
$this.inputmask("email");
}
}
The problem that is happening is as follows:
The mask is placed in the field correctly, however, when typing for example:
at the time the mask fields "@", "." are pressed, the field does not follow with the padding, ie if I type:
test (the moment I hit the '@' it proceeds, but as soon as I release it '@' it goes back to before), it always looks like this:
test (pointer stays here) @ ... '.' ...
To continue typing, you need to '@' be pressed and enter the next letter.
The mode that was called before this problem was directly in the input (it was changed since the inputs started to be generated all dynamically):
<input class="input-field" data-inputmask="'mask': '9', 'repeat': 10, 'greedy' : false" />
With jQuery:
$(document).ready(function(){
$(".input-field").inputmask();
});
I do not know if this is maybe a bug, or I misconceived some form the plugin, what would be a possible solution to this problem?