Today I Learned - Rocky Kev

TIL prohibit inserting text

POSTED ON:

TAGS:

You may want to prevent the user from pasting text copied from somewhere in the input fields (think carefully about whether it's worth it). This is very easy to do by tracking the event paste and calling its method preventDefault().

<input type="text"></input>
<script>
const input = document.querySelector('input');

input.addEventListener("paste", function(e){
e.preventDefault()
})

</script>

Via https://dev.to/ra1nbow1/6-useful-frontend-techniques-that-you-may-not-know-about-47hd


Related TILs

Tagged:

TIL CSRF Attacks

Cross-site Request Forgery (CSRF) is submitting post data from a fake site. To prevent CSRF attacks, web applications should implement measures such as requiring a valid CSRF token to be included with each request, checking the referer header, and using secure cookies.

TIL How to auto-grow textarea with pure css

To do this, you replicate the content of the '<textarea>' in an element that can auto expand height, and match its sizing.Same font, same padding, same margin, same border… everything.

TIL User-facing states