第一种:
<script type="text/javascript">
function check(form) {
if(form.userId.value=='') {
alert("请输入用户帐号!");
form.userId.focus();
return false;
}
if(form.password.value==''){
alert("请输入登录密码!");
form.password.focus();
return false;
}
return true;
}
</script>
<form action="login.do?act=login" method="post">
用户帐号
<input type=text name="userId" size="18" value="" >
<br>
登录密码
<input type="password" name="password" size="19" value=""/>
<input type=submit name="submit1" value="登陆" οnclick="return check(this.form)">
</form>
<script type="text/javascript">
function check(form) {
if(form.userId.value=='') {
alert("请输入用户帐号!");
form.userId.focus();
return false;
}
if(form.password.value==''){
alert("请输入登录密码!");
form.password.focus();
return false;
}
return true;
}
</script>
<form action="login.do?act=login" method="post" οnsubmit="return check(this)">
用户帐号
<input type=text name="userId" size="18" value="" >
<br>
登录密码
<input type="password" name="password" size="19" value=""/>
<input type=submit name="submit1" value="登陆">
</form>
第三种:<script type="text/javascript">
function check(form) {
if(form.userId.value=='') {
alert("请输入用户帐号!");
form.userId.focus();
return false;
}
if(form.password.value==''){
alert("请输入登录密码!");
form.password.focus();
return false;
}
document.myform.submit();
}
</script>
<form action="login.do?act=login" name="myform" method="post">
用户帐号
<input type=text name="userId" size="18" value="" >
<br>
登录密码
<input type="password" name="password" size="19" value=""/>
<input type=button name="submit1" value="登陆" οnclick="check(this.form)">
</form>