搜索内容不能为空

来源:百度知道 编辑:UC知道 时间:2024/06/30 15:12:51
请问如何使下面的代码在运行时可以检查表单,使“搜索内容不能为空”

<form action="/search.php" target="_window" method="get">
<table bgcolor="">
<tbody><tr><td valign="top" height="30" align="left">

<img border="0" alt="站内搜索" src="PNG-32/Search.png" align="middle"/>
<input maxlength="255" value="keywords"
name="q" title="enter keywords" size="18"/>
<input value="Search" name="sa" type="submit"/>
<input value="pub-6854204841389277" name="client" type="hidden"/>
<input value="1" name="forid" type="hidden"/>
<input value="GB2312" name="ie" type="hidden"/>
<input value="GB2312" name="oe" type=&

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
function check(){
var q=document.getElementById("q").value;
if(q.length==""){
alert("内容不能为空");
}
}
</SCRIPT>
</HEAD>

<BODY>
<form action="/search.php" target="_window" method="get">
<table bgcolor="">
<tbody><tr><td valign="top" height="30" align="left">

<img border="0" alt="站内搜索" src="PNG-32/Search.png" align="middle"/>
<input maxlength="255" value="keywords"
name="q" title="enter keywords" size="18"/>
<input value="Search" name="sa" type="submit" onclick="