Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js addeventlistener keyup not working on phone

//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">
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #addeventlistener #keyup #working #phone
ADD COMMENT
Topic
Name
9+3 =