我已经下载了模板表单以使用引导程序登录。当我尝试从电子邮件或密码字段获取值时,没有任何反应。
从看起来像这样
<form class="form-signin">
<img class="mb-4" src="https://getbootstrap.com/docs/4.3/assets/brand/bootstrap-solid.svg" alt="" width="72" height="72">
<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button onclick="autentica()" class="btn btn-lg btn-primary btn-block" type="submit" >Sign in</button>
</form>
我正在尝试使用的功能如下:
<script>
function autentica(){
var mail = document.getElementById("inputEmail").value();
alert(mail);
if(document.getElementById("inputEmail").value() == "admin@admin.cl" && document.getElementById("inputPassword").value() == "admin"){
document.location.href= "dashboard.html";
}
}
</script>
警报和更改页面均无效。 “ dashboard.html”文件位于同一文件夹中。
谢谢。
答案 0 :(得分:2)
没有函数value()
,但是它是(字符串)属性value
。因此正确的语法应为:var mail = document.getElementById("inputEmail").value;