<form name="frmtest" action="your.php" method="post" onsubmit="checkInput()">
<input type="text" name="whatever">
<input type="submit">
</form><script language="javascript">
function checkInput()
{
if (document.frmtest.whatever.value !="")
return true;
else
{
alert("whatever不能为空");
document.frmtest.whatever.focus();
return false;
}
}
</script>
<input type="text" name="whatever">
<input type="submit">
</form><script language="javascript">
function checkInput()
{
if (document.frmtest.whatever.value !="")
return true;
else
{
alert("whatever不能为空");
document.frmtest.whatever.focus();
return false;
}
}
</script>
onsubmit="checkInput()"
===>
onsubmit="return checkInput();"