主题:怎样写一个判断警告代码呢
hack119
[专家分:10] 发布于 2007-04-17 16:53:00
我有一个帐号和密码输入框表单,当我的IF 语句判断帐号和密码是空的时候就会弹出一个对话框,要求他输入信息,要怎样写呢
<input type="submit" name="submit" value="确定" onclick="check()">
回复列表 (共1个回复)
沙发
oyh484203 [专家分:5890] 发布于 2007-04-17 17:05:00
<input type="submit" name="submit" value="确定" onclick="return check()">
<script language=javascript>
<!--
function check(){
if (document.form1.username.value==""){
alert("用户名不能为空!");
document.form1.username.focus();
return false;
}
if (document.form1.password.value==""){
alert("密码不能为空!");
document.form1.password.focus();
return false;
}
}
//-->
</script>
我来回复