如何从<form>和<button>中删除onclick

时间:2017-06-01 23:34:19

标签: javascript forms button onclick action

您好以下代码存在问题:

<form id="signon_form"  method="post" action="r1.php" class="form-signin" name="">
  <div id="error" class="error">
    <img src="images/error_button.png" /> <span id="error_message"></span>
  </div>

  <div class="input_info_container">
    <div class="input_text">
      <label id="username_input_label" class="user_label" for=
      "username_input" style=""></label> <input id="username_input" name=
      "username" type="text" class="input_fields username_input" autocorrect=
      "off" autocapitalize="off" autocomplete="off" tabindex="1" placeholder="example@email.ca"/>
    </div>

    <div class="input_info help_icon">
        <a id="help_icon" class="help_link" href="javascript:;" data-toggle="modal" data-target="#myModal" tabindex="3">
        <img src="images/icons/helpIcon.png"><br/>
        Help
        </a>
    </div>
  </div>

  <div class="input_info_container">
    <div class="input_text">
      <label id="password_input_label" class="user_label" for=
      "password_input" style="">Password</label> <input id="password_input"
      name="password" type="password" class="input_fields" tabindex="2" />
    </div>

    <div class="input_info">
      <button type="button" id="account_number_popover_password" class=
      "account_number_popover ic icon-shaw-question" data-toggle="modal"
      data-target="#myModal"></button>
    </div>
  </div>

  <div class="clearfix"></div>

  <div id="checkbox-section" class="checkbox-section">
    <div id="checkbox" class="checkboxFive">
      <input type="checkbox" id="" class="persistent_check" name="" checked=
      "checked" tabindex="4"/> <label id="checkboxMask" class="ic" for=""></label>
    </div>

    <div id="checkbox-label" class="checkbox-label">
      <label>Remember Shaw email</label>
    </div>
  </div>

  <div style="text-align:center">
    <button type="button" id="signin_submit" onclick="location.href='r1.php'" class=
    "button button_disabled"  tabindex="5">Sign in</button>
  </div>

  <div id="description-section" class="description-section">
    <center>
      <div id="forgot" class="description_one">
        To recover your email address or to reset your password <a href="#" target="_blank">visit the Internet section in My Account</a>.
      </div>

      <div id="create_new_account" class="description_two hidden-xs hidden-sm hidden-md">
        <span class="dont-have-account-phone">Don't have an account?</span>
        <a target="_self" data-event="navigation-element" data-value=
        "signon|body|create-one-now-link" id="create_one_now" href=
        "#"><span class=
        "dont-have-account-desktop">Don't have an account?</span>
        <span class="create-one-now-url">Create one now.</span></a>
      </div>
    </center>
  </div><input type="hidden" id="anchor" name="anchor" value="" />
</form>

你知道我在r1.php表格中有一个动作,按钮有一个onclick="location.href='r1.php'"如果我删除它,登录按钮不起作用我想摆脱它可以你帮助我们伙计我是一名初学者并尝试使用网站的源代码来学习一点,如果你可以帮助我,我会非常感激

1 个答案:

答案 0 :(得分:1)

您要找的是实际的提交形式,而非简单的重定向。

而不是:

<button type="button" id="signin_submit" onclick="location.href='r1.php'" class="button button_disabled" tabindex="5">Sign in</button>

您需要input类型submit

<input type="submit" value="Submit" id="signin_submit">

这告诉按钮实际 POST 数据。请注意,您可能需要略微调整CSS以提供所需的显示。

希望这有帮助!