我一直在尝试获取密码以验证以下条件:
- 如果密码/用户名少于 5 个字符,将出现错误框
- 如果密码/用户名/两者都没有输入,会出现错误框
- 如果密码不正确,会出现错误框
- 如果密码正确,将出现提示登录成功的框
这是我的javascript编码:
<script> function validateForm()
{
var x=document.forms["Login"]["user"].value;
var y=document.forms["Login"]["pass"].value;
if (x==null || x=="")
{
alert("Error: Username and password must be entered ");
return false;
}
if(x.length<5){
alert("Your username must be at least \n5 characters long. \n Please try again.");
return false;
}
if (y==null || y=="")
{
alert("Error: Username and password must be entered");
return false;
}
if(y.length<5){
alert("Your username must be at least\n5 characters long.\n Please try again.");
//Login.txtpass.value = "";
//Login.txtpass.focus();
return false;
}
else{
alert("Error: Please check that you've entered and confirmed your password!");
return false;
}
alert("You entered a valid password: " + Login.pass.value);
return true;
}
</script>
目前上述所有 3 项均已成功发生,但现在在我创建脚本之前无法成功登录。我将如何通过 javascript 登录来执行此操作?
谢谢