方式一
$('#surname_id,#firstname_id').bind("keyup change",function() {
this.value=this.value.replace(/[^a-zA-Z]/g,'');//把非字符的替换为空
});
$('#certNo_id').bind("keyup change",function() {
this.value=this.value.replace(/[^a-zA-Z0-9]/g,'');
this.value=this.value.substr(0,18);
});
<input class="inputTipsRight width8Em" type="text" id="surname_id" name="surname" placeholder="请输入英文或拼音" />
方式二
$("#aolastName").on('keyup change input',function(e){
var keyword=this.value.toLowerCase();//获取文本框的值
if(keyword.match(/[^\a-\z\A-\Z]/g)!=null){//如果匹配到了,为空
this.value = "";
}
});