请高手帮忙看下我写的这个Javascript脚本文件验证用户名和密码在登录是不能为空那里错了,怎么不出现提示
<html><head></head><scriptlanguage="Javascript">functioncheck(){if(form1.username.val...
<html>
<head></head>
<script language="Javascript">
function check()
{if(form1.username.value=="" & pwd=="")
{alert ("错误提示:用户名和密码不能为空!");
return false;
}
if(form1.username.value=="")
{alert ("错误提示:用户名不能为空!");
return false;
}
if (form1.pwd.value=="")
{
{alert ("错误提示:密码不能为空!");
return false;
}
else
return true;
}
</script>
<body>
<form name="form1" action="" onsubmit="">
<p align="center">
用户名: <input type="text" name="username" />
<p align="center">
密码:<input type="password" name="pwd"/>
<p align="center">
<input type="submit" vlaue="登录" >
</form>
</body>
</html> 展开
<head></head>
<script language="Javascript">
function check()
{if(form1.username.value=="" & pwd=="")
{alert ("错误提示:用户名和密码不能为空!");
return false;
}
if(form1.username.value=="")
{alert ("错误提示:用户名不能为空!");
return false;
}
if (form1.pwd.value=="")
{
{alert ("错误提示:密码不能为空!");
return false;
}
else
return true;
}
</script>
<body>
<form name="form1" action="" onsubmit="">
<p align="center">
用户名: <input type="text" name="username" />
<p align="center">
密码:<input type="password" name="pwd"/>
<p align="center">
<input type="submit" vlaue="登录" >
</form>
</body>
</html> 展开
2个回答
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<script language="Javascript">
function check()
{
if(form1.username.value=="" && form1.pwd.value=="")
{
alert ("错误提示:用户名和密码不能为空!");
return false;
}
if(form1.username.value=="")
{
alert ("错误提示:用户名不能为空!");
return false;
}
if (form1.pwd.value=="")
{
alert ("错误提示:密码不能为空!");
return false;
}
return true;
}
</script>
<body>
<form id="form1" runat="server" name="form1" action="" onsubmit="">
<p align="center">
用户名:
<input type="text" name="username" />
<p align="center">
密码:<input type="password" name="pwd" />
<p align="center">
<input type="submit" value="登录" onclick="return check()">
</form>
</body>
</html>
<html>
<head>
</head>
<script language="Javascript">
function check()
{
if(form1.username.value=="" && form1.pwd.value=="")
{
alert ("错误提示:用户名和密码不能为空!");
return false;
}
if(form1.username.value=="")
{
alert ("错误提示:用户名不能为空!");
return false;
}
if (form1.pwd.value=="")
{
alert ("错误提示:密码不能为空!");
return false;
}
return true;
}
</script>
<body>
<form id="form1" runat="server" name="form1" action="" onsubmit="">
<p align="center">
用户名:
<input type="text" name="username" />
<p align="center">
密码:<input type="password" name="pwd" />
<p align="center">
<input type="submit" value="登录" onclick="return check()">
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询