首页  >  文章  >  web前端  >  站内搜索脚本例子六(javascript)_Javascript教程

站内搜索脚本例子六(javascript)_Javascript教程

黄舟
黄舟原创
2016-12-21 15:38:571041浏览

脚本说明:
第一步:把如下代码加入区域中

<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 &#39;<&#39;&#39;"); 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)! 


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn