第2个回答 2011-05-12
<form name="form" action="test.html" method="post" onsubmit="return check()">
<input type="text" id="name"/>
<input type="sumit" value="提交"/>
</form>
function check(){
var name = document.getElementById("name").value;
if(name == null || name == ''){
alert("不能为空");
return false;
}
return true;
}