Skip to content

Instantly share code, notes, and snippets.

@oops-wrong
Created March 21, 2018 14:10
Show Gist options
  • Save oops-wrong/3d6ed194b7f9f298eb15cafa2a06fc48 to your computer and use it in GitHub Desktop.
Save oops-wrong/3d6ed194b7f9f298eb15cafa2a06fc48 to your computer and use it in GitHub Desktop.
$(".input").inputmask({
regex: "([1-9]|10)",
colorMask: true,
onBeforeWrite: function (event, opts) {
if (event.type !== 'keypress') {
return;
}
var $targetInput = $(event.target);
var pastedValue = $targetInput.val();
var isAlreadyExist = $.makeArray($(".input")).some(function(input) {
var $input = $(input);
if ($input.is($targetInput)) {
return false;
}
return $input.val() === pastedValue;
});
if (isAlreadyExist) {
$targetInput.val('');
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment