$('#string').keyup(function() { if (this.value.match(/[^a-zA-Z]/g)) { this.value = this.value.replace(/[^a-zA-Z]/g, ''); } });