Answers for "How to make keyup on mobile devices?"

0

How to make keyup on mobile devices?

//This is because your Android has no real keyboard attached,
//it has a virtual one and it does not fire key- events.
//Since you're working with <input>, listen for input event instead of keydown or keyup.
//It solves your problem and also helps to handle paste.


document.getElementById("FirstName").addEventListener("input", alphaOnly, false);
document.getElementById("Surname").addEventListener("input", alphaOnly, false);


function alphaOnly(event) {
  event.target.value = event.target.value.replace(/[^a-z]/ig, '');
}

<input id="FirstName"><br>
<input id="Surname">
Posted by: Guest on April-04-2022

Code answers related to "How to make keyup on mobile devices?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language