<form onsumit="return validate()" action="b.htm">function validate(){
if(document.getElementById("姓名框ID").value==''){
alert("请输入姓名")
return false //****
}
return true
}
if(document.getElementById("姓名框ID").value==''){
alert("请输入姓名")
return false //****
}
return true
}
<input type=text name="UserName">
<input type=submit value="保存">
</form><script>
function InputCheck(theform)
{
if(theform.UserName.value==""){
alert("必须输入姓名");
theform.UserName.focus();
return false;
}}</script>