Search
 
SCRIPT & CODE EXAMPLE
 

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">
Comment

PREVIOUS NEXT
Code Example
Javascript :: Fetching data error and pending load check 
Javascript :: how to keep a child window always on top in electron js 
Javascript :: how to check for special charaters with spaces javascript 
Javascript :: dm discord.js 
Javascript :: .tolowercase 
Javascript :: react hook useeffect 
Javascript :: enable emmet in vscode for jsx 
Javascript :: a tag how to trigger ajax 
Javascript :: new date.gettime() is not a constructor 
Javascript :: key value pair array in javascript 
Javascript :: react state not updating immediately 
Javascript :: javascript detect paste contents 
Javascript :: wait 0.5 after function javascript 
Javascript :: Nuxt Use Nginx as reverse Proxy 
Javascript :: object.create() js 
Javascript :: javascript stack reverse 
Javascript :: if text is present make div hide 
Javascript :: next auth 
Javascript :: deparam javascript 
Javascript :: how to use jquery plugins in angular 8 
Javascript :: react navigation 
Javascript :: get file extension of path extendscript 
Javascript :: sequelize documentation 
Javascript :: Vue Chartjs label false 
Javascript :: javascript sort multi-dimensional array by column 
Javascript :: form status angular 
Javascript :: regex javascript online 
Javascript :: Multiple line string in JS 
Javascript :: convert image url to base64 javascript without canvas 
Javascript :: chrome storage local update 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =