gpt4 book ai didi

html - JQuery 登录错误消息仅有效一次

转载 作者:行者123 更新时间:2023-12-01 05:11:34 25 4
gpt4 key购买 nike

我有一个登录表单,当 ID 或密码错误时会显示错误消息。它可以工作,但如果用户多次输入错误的 ID 或登录信息,则该消息仅打印一次。如何修复它?这是我的 JS 脚本:

<script type="text/javascript">
$(document).ready(function() {
$("#buttonConnection").click(function(e) {
e.preventDefault();
$.post(
'mypost.php',
{
myID: $("#myID").val(),
myPassword: $("#myPassword").val()
},
function(data) {
if (data == 'Success') {
document.location.href = "dashboard.php"
} else {
$("#resultat").html('Bad ID or password !');
$("#resultat").addClass("alert alert-danger").fadeTo(3000, 0);
}
},
'text'
);
});
});
</script>

最佳答案

淡入淡出完成后,进行回调以重置 resultat HTML 和类:


<script type="text/javascript">
$(document).ready(function() {
$("#buttonConnection").click(function(e) {
e.preventDefault();
$.post(
'mypost.php',
{
myID: $("#myID").val(),
myPassword: $("#myPassword").val()
},
function(data) {
if (data == 'Success') {
document.location.href = "dashboard.php"
} else {
$("#resultat").html('ID or password incorrect !').addClass("alert alert-danger").fadeTo(3000, 0, function() {
$(this).html('').removeClass("alert alert-danger").fadeTo(0, 1);
});
}
},
'text'
);
});
});
</script>

关于html - JQuery 登录错误消息仅有效一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62022743/

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