Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Ajax: Copy - Paste thingy

Tags:

jquery

copy

paste

I have a form where a check an input field for its value and then i do an Ajax call using the typewatch plugin ( a small little thing which detects that the user has stopped typing after a predefined interval ). It works great.

As this field is a "coupon discount" in an order form, the value could be entered by copy pasting the "coupon code" from an email or something. It also works with Ctrl+C - Ctrl+V for Copy and paste but not when a user selects the text with the mouse, clicks copy from the context menu and then paste from this menu.

Is there a way in jQuery to check for this kind of behaviour in jQuery somehow?

like image 437
tsiger Avatar asked Nov 15 '22 10:11

tsiger


1 Answers

You could set a low time out (1 second) that checks is the value has changed since the last check.

You could also simply ignore it and when the form submits grab the contents of this coupon discount input and process it.

like image 53
Josh K Avatar answered Dec 09 '22 12:12

Josh K