【发布时间】:2022-02-12 05:42:02
【问题描述】:
这相当简单,我正在尝试使登录按钮起作用,如果电子邮件和密码中的内容与以下内容匹配,则重定向到不同的文件 (placeholder.html):
登录:管理员 密码:Password123
我还没有让登录按钮首先工作以重定向,并且id希望通过使用'onlick ='与js中的函数或id现在将其保留为按钮元素。
非常感谢您的帮助 :) 抱歉,如果这有点马虎,我第一次在这里寻求帮助哈哈
这是我到目前为止所拥有的,其中凹痕完全有效:
<!DOCTYPE html>
<html>
<head>
<title>Login page</title>
<link href="style." rel="stylesheet" type="text/css" />
<script src="script.js"></script>
</head>
<body>
<div class="login-page">
<div name="login" class="form">
<div class="title login" style="font-size: 25px; font-family: Roboto; padding-bottom: 25px;">
Login Form
</div>
<form class="login-form" action="login.php" method="post">
<input type="email_" placeholder="email"/>
<input type="password" placeholder="password"/>
<button id="login_button">login</button>
<p class="message" style="font-family: Roboto, sans-serif;">Not registered?
<a href="register.html">Create an account</a>
</p>
</form>
</div>
</div>
</body>
<script type="text/javascript">
document.getElementById("login_button").onclick = function () {
location.href = "#placeholder";
};
</script>
</html>
【问题讨论】:
-
location.href = "placeholder.html? -
使用
if检查输入值后。
标签: javascript html authentication