我有一个带有一些身份验证和验证的 php 登录表单。到目前为止,我想要运行的特定脚本如下:
<script type="text/javascript">
var login_attempts=3;
function check_form()
{
//This is where I want the code to check if the form is valid and will be submitted
{
alert("SuccessFully Logged In");
//Not sure if I need this as the form contains PHP so if the credentials are correct then tehy go to another page
}
else
{
if(login_attempts==0)
{
alert("No Login Attempts Available");
}
else
{
login_attempts=login_attempts-1;
alert("Login Failed Now Only "+login_attempts+" Login Attempts Available");
if(login_attempts==0)
{
document.getElementById("name").disabled=true;
document.getElementById("pass").disabled=true;
document.getElementById("form1").disabled=true;
}
}
}
return false;
}
</script>
我想要这个的原因是,在用户尝试登录 3 次后,我想要一个警报框显示一条消息,并阻止用户在框中输入任何内容。我实际上不想从数据库端锁定帐户,因为用户正在对用户名和密码以外的信息进行身份验证。
我对 Js 很陌生,如果我错过了任何东西,我很抱歉
相关分类