脚本说明:
第一步:把如下代码加入
区域中
站内搜索引擎
测试:输入关键字"java"
或中文字符"免费" 查询。
<script><br>function validate_form() {</p>
<p>txt = document.form.search.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>if (txt.indexOf("+") != -1){<br>alert("Search is invalid! Contains a '+''"); return;}<br>else {<br>jsi = new makeLinks(linksize);<br>searchLinks(jsi, txt);<br>document.write("<hr>");<br>document.write("<a href="http://www.php1.cn/">//将searchabledb2.htm替换为检索页的URL,以便访问者返回检索页。<br>}</p>
<p>}<br></script>
以上就是站内搜索脚本例子三(javascript)_Javascript教程的内容,更多相关内容请关注PHP中文网(www.php.cn)!