我的javascript代码如下:为什么页面重定向到没有完成表单的动作属性?
<script>
function check(){
if(document.getElementById("1").value=="") {
alert("enter 1st value");
document.getElementById("1").focus();
return;
}
else if(document.getElementById("2").value=="") {
alert("enter 2nd value");
document.getElementById("2").focus();
return;
}
return(true);
}
</script>
我的HTML页面
<form action="home.php" method="get">
<input type="text" id="1"></input>
<input type="text" id="2"></input>
<input type="text" id="3"></input>
<input type="submit"onclick="check()"></input>
</form>
我离开的时候故意对输入字段为空,它的重点是,但立即重定向到home.php页面,而不进行进一步用于输入值。