<form id="search_form" name="search_form" action="<?php echo site_url('test'); ?>" method="post">
<label>账号(*)</label><input type="text" name="accounts" value="<?php if(isset($param['accounts'])) echo $param['accounts']; ?>"/>
<input name="submit" type="submit" class="btnshort" value="查询" onclick="if (document.search_form.accounts.value=='' ){alert('请输入账号');return false;}" />
</form>
点击按钮时,会先检验表单search_form中的元素的名为accounts的值是否为空,如果为空,即提示用户输入账号。