电脑逻辑分区:我是初学者,帮忙看一下代码错在哪(JavaScript)

来源:百度文库 编辑:高校问答 时间:2024/05/01 18:43:25
<html>
<head><title>Do by myself</title></head>
<% String user=request.getParameter("user");%>
<script language="javascript">
function getCheck()
{ if (user.equal=="123")
{
window.alert("Your password is correct!!!!");
}
else
window.alert("Your password is wrong!!!!");
}
</script>
<body>
<form method="get">
<h3>Type in your password</h3>
<input type="password" name="user"><br>
<input type="button" value="Sure" onclick="getCheck()">
</form>
</body>
</html>
直接在IE中运行的,看不到错误,我是用Eclipse编程!

if (user.value=="123") ===>if(document.all.user.value=="123")

什么错误提示

什么错误提示

user=request.form(user)

是不是哪些符号错啦!

你那是jsp文件.得在jsp的环境下运行.不能在ie直接运行.
如想在ie 中直接实验.这样试试.
<html>
<head><title>Do by myself</title></head>
<script language="javascript">
function getCheck()
{
if(form1.user.value=="123")
{
window.alert("Your password is correct!!!!");
return false
}
else
{
window.alert("Your password is wrong!!!!");
return false
}
}
</script>
<body>
<form method="get" name=form1 >
<h3>Type in your password</h3>
<input type="password" name="user"><br>
<input type="submit" value="Sure" onclick="getCheck()">
</form>
</body>
</html>
保存为.html 文件.只有当你在文本框中输入123时.它才会显示正确信息.也就是Your password is correct!!!!
否则显示出错信息.