浏览代码

Merge pull request #805 from fquiroz01/patch-2

Disables paste
Robin Herbots 11 年之前
父节点
当前提交
580ea9bf3b
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      js/jquery.inputmask.js

+ 11 - 2
js/jquery.inputmask.js

@@ -1546,7 +1546,16 @@
                     }
                 }
 
-                var pasteValue = $.isFunction(opts.onBeforePaste) ? (opts.onBeforePaste.call(input, inputValue, opts) || inputValue) : inputValue;
+                var pasteValue = inputValue;
+                if($.isFunction(opts.onBeforePaste)) {
+                    pasteValue = opts.onBeforePaste.call(input, inputValue, opts);
+                    if (pasteValue === false) {
+                        e.preventDefault();
+                        return false;
+                    }
+                    if (!pasteValue)
+                        pasteValue = inputValue;
+                }
                 checkVal(input, true, false, isRTL ? pasteValue.split('').reverse() : pasteValue.split(''));
                 $input.click();
                 if (isComplete(getBuffer()) === true)
@@ -2145,4 +2154,4 @@
         };
     }
     return $.fn.inputmask;
-})(jQuery);
+})(jQuery);