Skip to content

Update numeric/jquery.numeric.js #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion numeric/jquery.numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@ $.fn.numeric.keypress = function(e)

$.fn.numeric.keyup = function(e)
{
// Determine if it is a paste action (CTRL+V or SHIFT+INS)
var paste = false;
// get the key that was pressed
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
// allow or deny Ctrl+V (paste), Shift+Ins
if((e.ctrlKey && key == 118 /* firefox */) || (e.ctrlKey && key == 86) /* opera */
|| (e.shiftKey && key == 45)) {
paste = true;
}

var val = $(this).val();
if(val && val.length > 0)
// Only process pate on key up event. Then CTRL+A, Y, Z ... actions will be process normally.
if(val && val.length > 0 && paste)
{
// get carat (cursor) position
var carat = $.fn.getSelectionStart(this);
Expand Down