Ciao,

codice:
<script type="text/javascript">
            function consentiti(campo) {
                var re = new RegExp("^[A-Za-z0-9\+\_\-]+$","");
                var valore = campo.value;  
                for ( var i = 0; i < valore.length; i++ ) {
                    if (!valore.charAt(i).match(re)) {
                        campo.value = valore.substring(0, i);
                        return;
                    }   
                }
            }  
        </script>

<input type="text" name="" onkeyup="consentiti(this)" />

Massimo.