funziona tutto
.. tranne che:
con Opera, non mi fa inserire proprio nessun carattere in parole povere ritorna sempre false; mi potete aiutare, non capisco
ecco il mio codice (che è praticamente uguale a quello suggeritomi da carlo marx)
codice:
function normalOnly(mode, oToCheckField, oKeyEvent) {
if(mode=='normal'){
var nChar = (oKeyEvent || /* IE */ window.event || { charCode: 0 }).charCode;
return nChar === 0 || /[a-z0-9\s]/i.test(String.fromCharCode(nChar));
}else if(mode=='number')
{
var nChar = (oKeyEvent || /* IE */ window.event || { charCode: 0 }).charCode;
return nChar === 0 || /^\d+$/i.test(String.fromCharCode(nChar));
}
}
e questa è il tag HTML a cui è associata la funzione
codice:
<input type="text" id="textgentel" onpaste="return(false)" onkeypress="return(normalOnly(\'number\', this, event));" value="'+tel+'">
grazie