gpt4 book ai didi

javascript - 无需点击提交即可登录

转载 作者:行者123 更新时间:2023-11-29 13:02:20 25 4
gpt4 key购买 nike

所以我正在研究这个项目,我在其中创建了一个管理区域。当我在开发登录功能时,我想要一个这样的功能:-一旦用户填写了所有条目(用户名和密码),系统就会自动登录。他不需要点击提交按钮。同样,如果密码不正确,他应该收到一条错误消息。我怎样才能实现这个功能?我想这可以通过 jQuery 和 Ajax 来完成,而我对它们都一无所知。如果有人能引导我朝正确的方向前进,那就太好了。

Admin_login.php

<form class="form-horizontal" action="****" method="post" id="login">
<fieldset>
<div class="input-prepend" title="Username" data-rel="tooltip">
<span class="add-on"><i class="icon-user"></i></span><input autofocus class="validate[required] text-input, input-large span10" name="username" id="username" type="text" placeholder="Username"/>
</div>
<div class="clearfix"></div>

<div class="input-prepend" title="Password" data-rel="tooltip">
<span class="add-on"><i class="icon-lock"></i></span><input class="validate[required] text-input, input-large span10" name="password" id="password" type="password" placeholder="password"/>
</div>
<div class="clearfix"></div>
<div class="clearfix"></div>
<p class="center span5">
<button type="submit" class="btn btn-primary">Login</button>

</p>
</fieldset>
</form>

数据库表

Column Name    Type
Username VARCHAR
Password VARCHAR

最佳答案

我写了一个git。
这是链接: https://github.com/FabioSorre/HTML-PHP-AJAX-JQUERY-JS

步骤如下:

  • Html:无表单操作 (action="") 并指定方法(客户端)
  • Javascript/Jquery:onSubmit 函数调用(客户端)
  • 设置 JSON 回调(客户端)
  • Php 文件(设置 json_encode、操作和响应)(服务器端)
  • 显示结果(客户端)

关于javascript - 无需点击提交即可登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23170632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com