首页 > 解决方案 > 按下回车键时表单不提交,即使有提交按钮

问题描述

如标题所示,如果我按回车,我的表单默认不会提交。我宁愿不要添加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>

标签: htmlcss

解决方案


对于提交表单,您需要添加功能而不是发送 from 到服务器,如下所示:

<form action="sendForm()" id="login-form"...>

推荐阅读