js 過濾敏感詞


< html >
< head >
     < title >Bad Words Example</ title >
     < script type = "text/javascript" >
 
             function filterText(sText) {
                 var reBadWords = /badword|anotherbadword/gi;
                 return sText.replace(reBadWords, "****");
             }
 
             function showText() {
                 var oInput1 = document.getElementById("txt1");
                 var oInput2 = document.getElementById("txt2");
                 oInput2.value = filterText(oInput1.value);
             }
     </ script >
</ head >
< body >
     < P >
     < textarea rows = "10" cols = "50" id = "txt1" >badword anotherbadword</ textarea >< br />
     < input type = "button" value = "Filter Bad Words" onclick = "showText()" /></ p >
     < P >Filtered Text:< br />
     < textarea rows = "10" cols = "50" id = "txt2" ></ textarea ></ p >
 
</ body >


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM