- <!DOCTYPE html>
- <html>
- <head><title></title></head>
- <body>
- <textarea onchange="replace(this)" id="r-textarea" required maxlength="200" style="border:5px
- dotted red;color:red;width:500px;height:300px;outline:none"onfocus="borderColor(this);"onblur="clearTimeout(oTime);">
- </textarea>
- </html>
- <script>
- var arr=['\ud83c[\udf00-\udfff]','\ud83d[\udc00-\ude4f]','\ud83d[\ude80-\udeff]'];
- function replace(inp){
- inp.value=inp.value.replace(arr.join('|'),'')
- }
- function borderColor(){
- if(self['r-textarea'].style.borderColor=='red'){
- self['r-textarea'].style.borderColor = 'yellow';
- }else{
- self['r-textarea'].style.borderColor = 'red';
- }
- oTime = setTimeout('borderColor()',400);
- }
- </script>
来源: http://www.qdfuns.com/article/38878/1606301927cf14f81e79c8051ee57d4c.html