<script language="javascript">
function check()
{
var form=document.all.form1
if(form.username.value=="")
{
alert("不能为空!")
form.username.focus()
return false;
}
form.action="1.html"
form.submit()
form.action="2.html"
return true;
}
</script>
<form name="form1" method=post οnsubmit="return check()" target="_blank">
<input type="text" name="username">
<input type="submit">
</form>