Se vuoi farlo lato client:
codice:<html> <script> //controllo il browser var strUserAgent = navigator.userAgent.toLowerCase(); var isIE = strUserAgent.indexOf("msie") > -1; var isNS6 = strUserAgent.indexOf("netscape6") > -1; var isNS4 = !isIE && !isNS6 && parseFloat(navigator.appVersion) < 5; //regular expressions var regExpr = /\D/; //Se vuoi solo lettere minuscole o maiuscole //var regExpr = /[a-zA-Z]/; //controllo cosa è stato premuto function checkme(objEvent) { var Codice, Carattere; if (isIE) { Codice = objEvent.keyCode; } else { Codice = objEvent.which; } Carattere = String.fromCharCode(Codice); if (!regExpr.test(Carattere)) { alert("Carattere non valido!\nCodice = " + Codice + "\nCarattere =" + Carattere); return false; } } </script> <input type="text" onkeypress="return checkme(event)" ID="Text1"> </html>
Fammi sapere ciao
Kalman

Rispondi quotando