html - 按下回车键时表单不提交,即使有提交按钮
问题描述
如标题所示,如果我按回车,我的表单默认不会提交。我宁愿不要添加js代码,但我无法解释,但我无法解释它有什么问题。有什么建议么?我还尝试在没有结果的输入中更改我的按钮。如果我单击登录按钮,表单将起作用。
// 而不是“#”,显然有一个指向另一个 html 页面的链接。如果我点击按钮一切正常,我希望当用户插入他的电子邮件和密码时,他可以按回车键登录
<div class="login-box" style="display:block">
<div class="form-header" style="padding-left:10px;padding-right:10px;">
<div class="content-form">
<form action="#" id="login-form" class="login-form smart-form client-form text-center">
<div class="login-input">
<input type="email" placeholder="Email Address" autocomplete='off' id="username" name="email" value="" tabindex="1" required><i class="fa fa-user fa-lg fa-fw" aria-hidden="true"></i>
<b class="tooltip tooltip-top-right"><i class="fa fa-user txt-color-teal"></i> Please enter
your email
address/username</b>
</div>
<div class="login-input" style="margin-top:20px;">
<input type="password" placeholder="Password" autocomplete='off' id="password" name="password" value="" tabindex="2">
<i class="fa-lg fa-fw fa fa-lock"></i>
<b class="tooltip tooltip-top-right"><i class="fa fa-lock txt-color-teal"></i> Enter your
password</b>
<div class="note"></div>
</div>
<div class="login-input hidden" style="margin-top:20px;text-align:right;">
<input class="checkbox form-checkbox" type="checkbox" name="remember" checked="checked" id="check" />
<label class="form-checkbox-label" for="check">Stay signed in</label>
</div>
<div style="margin-top:30px;">
<button id="loginButton" type="submit" class="btn btn-login" tabindex="3">login</button>
</div>
</form>
</div>
</div>
解决方案
对于提交表单,您需要添加功能而不是发送 from 到服务器,如下所示:
<form action="sendForm()" id="login-form"...>
推荐阅读
- windows - windows中删除后恢复的html文件看起来不一样。如何恢复以前的格式?
- javascript - 如何从 Web 浏览器与 python 服务器通信?
- xamarin - Xamarin.Forms 启动项目无法在本地 github-repository 中运行
- vba - 使用 VBA 匹配和索引功能
- c# - 文件路径在本地工作,但在 Heroku 上不工作
- html - 我可以使用“Figma”而不是 HTML、CSS
- sqlite - WITH RECURSIVE 循环遍历数据库中的每一天,每个日期的两个日期之间的 SUM 数
- bash - 在 bash 脚本中拒绝低于最小大小的下载
- keras - 扩展新数据 LSTM
- regex - 排除引号之间的所有内容