验证用户输入的代码,为什么return了,还是会提交?
<script language="javascript">
function check() {
if (document.form.sID.value == "" || document.form.sID.value == null) {
alert("学号不能为空");
return;
}
else if (document.form.name.value == "" || document.form.name.value == null) {
alert("姓名不能为空");
return;
}
else {
document.form.submit();
}
}
</script>
我没输用户名提交后,提示“姓名不能为空”,但return没用? 我确定后,他还是会提交到我action=""中的页面去。