下面代码加到HEAD与TITLE之间:
<script type="text/javascript">
function check() {
if (document.all.loginForm.username.value == "") {//判断用户名输入框是否为空
alert("请输入用户名!");
document.all.loginForm.username.focus();//将光标定位到用户名输入框
return false;
}
if (document.all.loginForm.password.value == "") {//判断密码输入框是否为空
alert("请输入密码!");
document.all.loginForm.password.focus();//将光标定位到密码输入框
return false;
}
return true;
}
</script>
把下面代码加到FORM表单属性:
onsubmit="return check();
|