Skip to content

Commit

Permalink
Use event listeners instead of deprecated event
Browse files Browse the repository at this point in the history
  • Loading branch information
amstilp committed Mar 22, 2024
1 parent 6337e92 commit d5a72c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions primed/static/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Handle paste event for text inputs with maxlength.
const checkPasteLength = (e) => {
var paste = (event.clipboardData || window.clipboardData).getData("text");
var paste = (e.clipboardData || window.clipboardData).getData("text");
maxlength = e.target.getAttribute("maxlength");
if (paste.length > maxlength) {
alert("String longer than allowed maximum length of " + maxlength + " characters:\n" + paste)
Expand All @@ -12,4 +12,8 @@ const checkPasteLength = (e) => {
}

var textInputs = $('form').find("input[maxlength]")
textInputs.on("paste", checkPasteLength);
// textInputs.on("paste", checkPasteLength);
for(var i = 0; i < textInputs.length; i++){
// Console: print the clicked <p> element
textInputs[i].addEventListener("paste", checkPasteLength);
}

0 comments on commit d5a72c2

Please sign in to comment.