通过replace来替换不符合要求的数据
$(document).on('keyup','[name="layerName"]',function(){
$(this).val(testLayerName($(this).val()));
});
$(document).on('paste','[name="layerName"]',function(){
$(this).val(testLayerName($(this).val()));
});
function testLayerName(str){
str = str.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g,'');
return str;
}