图片做按钮的问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 22:45:46
<!--
function checkf()
{
var str=document.sform.key;
if(str.value.replace(/^\s+|\s+$/g,"")=="")
{
alert("请输入搜索的关键字!");
str.focus();
return false;

}
}
//-->
<form name=sform action="Search.asp" method=post>
<input class=fminpt name=key value=''>
<INPUT type="image" src="/images/so.gif"onClick="document.sform.submit()">"
</form>

为什么我检查到输入内容为空。可还是照样提交了表单了。能不能检到内容为空就不提交

你应该
<form name=sform action="Search.asp" method=post>
<input class=fminpt name=key value=''>
<INPUT type="image" src="/images/so.gif"onClick="return checkf();">"
</form>
图片可以直接做按钮的,
也可以给一个input背景也一样可以实现的.