Created
March 21, 2018 14:10
-
-
Save oops-wrong/3d6ed194b7f9f298eb15cafa2a06fc48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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