0
event.originalEvent.clipboardData.getData('Text').match(/[^\d]/))

In the above code I don't understand the originalEvent, and clipboardData process. Please explain it to me briefly.

Huangism
  • 16,278
  • 7
  • 48
  • 74
Anand Ganesh S S
  • 128
  • 1
  • 2
  • 9
  • Check http://stackoverflow.com/questions/16674963/event-originalevent-jquery and http://stackoverflow.com/questions/3640187/how-can-i-modify-pasted-text – Bryant Miano Mar 25 '15 at 19:58

1 Answers1

4

You have posted code that matches a string against a regular expression (short: regex; a general pattern matching syntax). This string has been obtained through some objects and their properties/methods in response to a jquery event. In detail:

  • event: a jquery event object.

  • originalEvent: the underlying javascript event object.

  • clipboardData: this property reveals that the originalevent has been a ClipboardEvent (more specifically; a paste event) from the ClipboardAPI. The property returns a DataTransfer object that contains the typed data from the clipboard.

  • getData: This method of the DataTransfer object extracts textual data from the clipboard contents.

  • match: This method retrieves all non-digits from the string as an array or returns null if the string contains digits only.

Note

Most of the links refer to the MDN ( Mozilla Developer Network ), an excellent resource for web development. These pages usually contain links to the pertinent standards, most of which are accessible through the w3c web site too.

Consult these resources frequently and thoroughly, even if it takes time ! - they will vastly improve your development skills and actually save you time in the long run!

I have no affiliations with MDN or W3C apart from using the infos and tools they offer.

Community
  • 1
  • 1
collapsar
  • 17,010
  • 4
  • 35
  • 61