ソースを参照

Disables paste

Disable paste for the user. for example

$("#test").inputmask('9999', {onBeforePaste: function (pastedValue) { return false; }})

The user can't paste in the control.
fquiroz01 11 年 前
コミット
2af6d2341b
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);