Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js paste event

const target = document.querySelector('div.target');

target.addEventListener('paste', (event) => {
    let paste = (event.clipboardData || window.clipboardData).getData('text');
    paste = paste.toUpperCase();
 
    const selection = window.getSelection();
    if (!selection.rangeCount) return false;
    selection.deleteFromDocument();
    selection.getRangeAt(0).insertNode(document.createTextNode(paste));

    event.preventDefault();
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: set auto-hide toast javascrpt 
Javascript :: short date angular pipe 
Javascript :: javascript disable copy paste 
Javascript :: check if date is after or before with moment 
Javascript :: css find overflowing elements 
Javascript :: react absolute path 
Javascript :: javascript set div height 
Javascript :: telegraf js sendmessage 
Javascript :: how to select all elements of type js 
Javascript :: js array value that appears odd number of times 
Javascript :: UnhandledPromiseRejectionWarning: MongoNotConnectedError: 
Javascript :: how to repeat prompt with the same variable in javascript 
Javascript :: ionic (Emitted value instead of an instance of Error 
Javascript :: connect vite with node js 
Javascript :: jquery select radio 
Javascript :: use history react router dom 
Javascript :: linebreak-style eslint 
Javascript :: Convert JS date time to SQLSERVER datetime 
Javascript :: how to reset form values in jquery 
Javascript :: node js cron restart every round hour 
Javascript :: vs code prevent auto grml closing in js files 
Javascript :: python phantomjs current url 
Javascript :: electron js Not allowed to load local resource 
Javascript :: c# json foreach key value 
Javascript :: loopback order by limit 
Javascript :: how 2 subtract 2 dates using moment.js 
Javascript :: js nullish 
Javascript :: sum the all values from an array 
Javascript :: addeventlistener input 
Javascript :: how to check if iframe is loaded 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =