Bonjour,

J'ai créé une fonction js qui vérifie lors de la saisie dans un champ (input) si les caractères correspondent bien. Ma fonction marche mais sur mobile ça ne marche pas. Je ne connais l'astuce avec l'événement onkeyup sur mobile. J'ai besoin de votre aide. Merci par avance !

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
<!-- HTML -->
<input type="text" name="np" value="" maxlength="25" onkeyup="verif_text(this);">
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
function verif_text(champ){
    var chiffres = new RegExp("[a-zA-Z ?.-=+,]");
    var verif;
    var points = 0;
 
    for(x = 0; x < champ.value.length; x++){
       verif = chiffres.test(champ.value.charAt(x));
       if(champ.value.charAt(x) == "."){points++;}
       if(points > 1){verif = false; points = 1;}
       if(verif == false){champ.value = champ.value.substr(0,x) + champ.value.substr(x+1,champ.value.length-x+1); x--;}
     }
}