JS 处理输入框表情

 

oninput   input/textarea  监听输入状态

 

function filteremoji(content){
var ranges = [
'\ud83c[\udf00-\udfff]',
'\ud83d[\udc00-\ude4f]',
'\ud83d[\ude80-\udeff]'
];
emojireg = content .replace(new RegExp(ranges.join('|'), 'g'), '');
return emojireg;
}

 

$("input,textarea").on('input propertychange',function(){
var content=$(this).val();
var ranges = [
'\ud83c[\udf00-\udfff]',
'\ud83d[\udc00-\ude4f]',
'\ud83d[\ude80-\udeff]'
];
emojireg = content .replace(new RegExp(ranges.join('|'), 'g'), '');

$(this).val(emojireg);
})

 

posted @ 2017-08-05 19:30  121686076  阅读(1644)  评论(0编辑  收藏  举报