Home  >  Article  >  Web Front-end  >  Site search script example six (javascript)_Javascript tutorial

Site search script example six (javascript)_Javascript tutorial

黄舟
黄舟Original
2016-12-21 15:38:571041browse

Script instructions:
Step 1: Add the following code to the area

<script><br><!-- 如下是表单合法性检查,主要是避免一些非法字符的查询! --><br>function validate_form()<br>{<br>txt = document.form.search.value;<br>newindex = document.form.numhits.selectedIndex;<br>dahits = document.form.numhits[newindex].value;<br>newindexb = document.form.whichdir.selectedIndex;<br>dadir = document.form.whichdir[newindexb].value;<br>if (txt.indexOf(".") != -1){<br>alert("Search is invalid! Contains a '.'"); return;}<br>if (txt.indexOf(",") != -1){<br>alert("Search is invalid! Contains a ','"); return;}<br>if (txt.indexOf("@") != -1){<br>alert("Search is invalid! Contains a '@''"); return;}<br>if (txt.indexOf("!") != -1){<br>alert("Search is invalid! Contains a '!''"); return;}<br>if (txt.indexOf("#") != -1){<br>alert("Search is invalid! Contains a '#''"); return;}<br>if (txt.indexOf("$") != -1){<br>alert("Search is invalid! Contains a '$''"); return;}<br>if (txt.indexOf("%") != -1){<br>alert("Search is invalid! Contains a '%''"); return;}<br>if (txt.indexOf("^") != -1){<br>alert("Search is invalid! Contains a '^''"); return;}<br>if (txt.indexOf("&") != -1){<br>alert("Search is invalid! Contains a '&''"); return;}<br>if (txt.indexOf("*") != -1){<br>alert("Search is invalid! Contains a '*''"); return;}<br>if (txt.indexOf("(") != -1){<br>alert("Search is invalid! Contains a '(''"); return;}<br>if (txt.indexOf(")") != -1){<br>alert("Search is invalid! Contains a ')''"); return;}<br>if (txt.indexOf("[") != -1){<br>alert("Search is invalid! Contains a '[''"); return;}<br>if (txt.indexOf("]") != -1){<br>alert("Search is invalid! Contains a ']''"); return;}<br>if (txt.indexOf(";") != -1){<br>alert("Search is invalid! Contains a ';''"); return;}<br>if (txt.indexOf(":") != -1){<br>alert("Search is invalid! Contains a ':''"); return;}<br>if (txt.indexOf("<") != -1){<br/>alert("Search is invalid! Contains a '<''"); return;}<br/>if (txt.indexOf(">") != -1){<br>alert("Search is invalid! Contains a '>''"); return;}<br>if (txt.indexOf("?") != -1){<br>alert("Search is invalid! Contains a '?''"); return;}<br>if (txt.indexOf("=") != -1){<br>alert("Search is invalid! Contains a '=''"); return;}<br>if (txt.indexOf("+") != -1){<br>alert("Search is invalid! Contains a '+''"); return;}<br>else<br>{<br>jsi = new makeLinks(linksize);<br>searchLinks(jsi, txt, dahits, dadir);<br>document.write('</OL>');<br>document.write('<font color=red>....... 查询结果结束 .......</font><P>');<br>document.write('<hr>');<br>document.write('</body></html>');<br>}</p> <p>}<br></script>


 
 


 


关键字(小写字符,支持中文):  

 





返回记录数:  

检索分类  

 







 




 
 

 以上就是站内搜索脚本例子六(javascript)_Javascript教程的内容,更多相关内容请关注PHP中文网(www.php.cn)! 


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn