日期:2014-05-17 浏览次数:20694 次
var $ = function(f){return document.getElementById(f);} function check_con(){ var f= "content"; //需要检测的内容 var kw; var mess = $(f).value.replace(/<[^>]+>/g,"");//去掉所有的html标记; var clearhtml =/<(?:.|s)*?>| /g;//去掉所有的html标记和 mess = html.replace(/<[^>]+>/g,"");//去掉所有的html标记; mess = mess.replace(/(^\s+)|(\s+$)/g,"");//去掉前后空格 mess = mess.replace(/\s/g,"");//去除文章中间空格 mess = mess .replace(clearhtml,''); for(var i=0;i<mess.length;i++){ kw = mess[i].toLowerCase(); if(kw =='h'){ var http = kw+mess[i+1]+mess[i+2]+mess[i+3];if(http.toLowerCase() == 'http'){alert('存在网址');return false;}} if(kw =='.'){ var url = mess[i+1]+mess[i+2]+mess[i+3]; var surl = mess[i+1]+mess[i+2]; var tourl = mess[i+1]+mess[i+2]+mess[i+3]+mess[i+4]; url = url.toLowerCase();surl =surl.toLowerCase();tourl =tourl.toLowerCase(); if(url == 'com'|| url=='net' || url=='org'|| surl == 'cn' ||surl=='cc' || tourl=='info' || tourl=='name' || surl=='uk') alert('存在网址');return false;} if(kw == 'q' && mess[i+1].toLowerCase()=='q' || mess[i+1].toLowerCase()==':'){alert('存在QQ');return false;} if(kw == '@' && mess[i+1].toLowerCase()=='q'){alert('存在邮箱');return false;} } }?