A, replace individually replaced with
Cons: bad language filter set too low
. 1 var oSize = $ ( the this .) .Siblings ( '. Flex-text-wrap') Find ( 'INPUT-Comment.' ) .Val (); 2 the console.log (oSize); . 3 // filtering network language violence the begin . 4 var B = oSize.replace (/ roller / G, '*' ); . 5 var C = b.replace (/ SB / G, '*' ); . 6 var D = c.replace (/ TMD / G, '*' ); 7 / * 8 ideas 1: bad language codes exist in an array, having received the comment input, robin 9 disadvantages: bad language set multiple, full feeling something wrong code plug 10 present results: failed 11 failed The reason: the effect of the actual page can not be replaced by cycle 12 Ideas 2: swearing existence of a local txt text, use the time until then call the 13 ideas 3: There is a local TXT text swearing, after analysis using Python local upload page 14 * / 15 // filter network violent language End 16 oSize = d ;
Second, regular filter
This is the only one currently swearing filter replacement
bug:
1, enter the swearing still appear in the comment section
2, normal no problem statement can not be displayed
. 1 var oSize = $ ( the this .) .Siblings ( '. Flex-text-wrap') Find ( 'INPUT-Comment.') Val ();. // Get the input content 2 the console.log (oSize); // the legend is pressed F12, you can see the log to write, but I just try and not useful 3 4 // filter network violent language the begin 5 var REG = / (a) | (b) / G; // this is regular expression, and you will want to filter words on here 6 var str = oSize.match (REG) .join ( "\", \ ""); // match words can conform to pick out an array composed of 7 Alert ( "Please do not use the \" "+ str +" \ " uncivilized vocabulary")!;
Third, Unknown
bug:
1, I did not understand (Wulian)
2, with this shielding does not work, and review the case, can not be displayed
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head><body> <input type="text" id="Name" /><input type="button" value="Test" onclick="ck()" /> </body> </html> <script type="text/javascript">function ck(){ var obj=document.getElementById("Name") ; IF) tempKw = kw.split ( ","varto shield keywords with a comma in the multiple text input state//kw = "ah, I, you, he";var (tempKw.length> =. 1 ) { for (I = 0; I <tempKw.length; I ++ ) { IF (obj.value.indexOf (tempKw [I])> = 0 ) { Alert ( "do not use text-sensitive ! " ); BREAK ; // exit the loop } } } } </ Script>
Four, Unknown
bug:
Ibid bug code
var oPublish = document.getElementById ( "publish" ); var oMessage = document.getElementById ( 'Message' ); var oReceive = document.getElementById ( 'the receive' ); var sensitiveWords = [ 'Zhao Chengliang', 'Wu Xudong', 'Xue Jiangjiang ',' Wang ',' Sun Yi ',' letter D '' is still open ' ]; oPublish.onclick = function () { var sMessage = oMessage.value; IF (sMessage ==' ' ) { Alert ( ' Please enter the message '! ); return false ; } // sensitiveWords.forEach.(function(v){ // sMessage = sMessage.replace(v , '***'); // }); sensitiveWords.forEach(function (v) { while(sMessage.indexOf(v) !== -1){ sMessage = sMessage.replace(v, '***'); } }); var oLi = document.createElement('li'); oLi.innerHTML =sMessage; oReceive.appendChild(oLi); oMessage.value = '';