<input id="text_id" name="" type="text" value="" placeholder="请输入英文字母" maxlength="12"/ >
<input id="text_content" name="" type="text" value="" placeholder="请输入阿拉伯数字" maxlength="12"/ >
$(function(){
var rep = /(^\d+)|(^[a-zA-Z]+)/;
$("input").on("input propertychange",function(e){
var _this = this;
this.value.replace(rep,function($1,$2,$3){
if($2) _this.value = $2;
if($3) _this.value = $3;
})
})
});
转载于:https://my.oschina.net/u/248889/blog/659243