View中代码:
<input type="text" class="searchText" id="searchText"/> <input type="button" value="" onclick="Cheak()" class="searchBtn" id="searchBtn"/> <script type="text/javascript"> function Cheak() { var keys = $("#searchText").val(); if (keys.trim() == "") { alert("请输入要搜索的内容"); return false; } if (keys == "--" || keys == "'") { alert("请勿输入非法字符"); return false; } window.location.href = "/Search/SearchList/"+keys.toString(); } </script>