1、html
<div id="nav_mid"> <!--search start--> <div id="search" class=""> <div class="keys f_l"> {if $searchkeywords} {$lang.hot_search} : {foreach from=$searchkeywords item=val} <a href="search.php?keywords={$val|escape:url}">{$val}</a> {/foreach} {/if} </div> <form id="searchForm" name="searchForm" method="get" action="search.php" onSubmit="return checkSearchForm()" class="f_r" style="_position:relative; top:5px;"> <select name="category" id="category" class="B_input" style="width:100px;height: 35px;border:2px solid red;"> <option value="0" style="background:red;color:white;">{$lang.all_category}</option> {$category_list} </select> <input name="keywords" type="text" id="keyword" value="{$search_keywords|escape}" class="B_input" style="width:350px;height: 29px;;border:2px solid red;margin-right:0px;"/> <input name="imageField" type="submit" value="搜 索" class="" style="cursor:pointer;width:80px;height:35px;background:red;color:white;border:2px solid red;margin-left:0px;" /> <a href="search.php?act=advanced_search" style="cursor:pointer;width:80px;height:35px;color:#666;">{$lang.advanced_search}</a> </form> </div> <!--search end--> </div>2、js
<script type="text/javascript"> {literal} <!-- function checkSearchForm() { if(document.getElementById('keyword').value) { return true; } else { alert("{$lang.no_keywords}"); return false; } } --> {/literal} </script>