Buongiorno a tutti,
come faccio a legare un evento all'inserimento di un dato in un input text da dispositivi mobile?
L'onchange non va bene.
La funzione che vorrei richiamare è:
codice:
<script type="text/javascript">
function onlyNumbers(evt) {
var theEvent = evt || window.event;
/*Questa condizione ternaria è necessaria per questioni di compatibilità tra browser se "evt.which" non viene preso, usa "event.keyCode" */
var charCode=(evt.which)?evt.which:event.keyCode;
if(charCode>31 && (charCode<48 || charCode>57)){
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
</script>
Chiamata con onkeypress va ovviamente solo da tastiera, come posso farlo andare anche su mobile?
Fatemi sapere.
Grazie mille.