In text fields of my JSP, I wish to know whether user is typing in the data or just pasting.
How can I identify this using javascript ?
EDIT: As per Andy’s answer I know how I can go about it, but still curios how those guys wrote onpaste event.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Safari, Chrome, Firefox and Internet Explorer all support the
onpasteevent (not sure about Opera). Latch onto theonpasteevent and you will be able to catch whenever something is pasted.Writing this is simple enough. Add the event handler to your input using html:
or JavaScript-DOM:
From what I’ve read, Opera does not support the
onpasteevent. You could use theDOMAtrrModifiedevent, but this would fire even when scripts change the value of the input box so you have to be careful with it. Unfortunately, I’m not familiar with mutation events so I wouldn’t like to mess this answer up by writing an example that I wouldn’t be confident of.