gpt4 book ai didi

javascript - asp.net ajax - 导致验证 onBlur 事件

转载 作者:行者123 更新时间:2023-11-30 06:03:31 25 4
gpt4 key购买 nike

我想在没有回传的情况下检查登录是否存在。

<script type="text/javascript">
//validation login exists
function ValidateLoginExists(source, args) {
var exists;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: '/account/userRegister.aspx/LoginExists',
data: "{'login': '" + args.Value + "'}",
dataType: "json",
async: false,
success: function (result) {
exists = result.d;
}

});

args.IsValid = !exists;
}
</script>

<div>
<b>Login</b>
<uc:TextBox ID="txtLogin" runat="server"
onBlur="ValidateLoginExists(null, $('#<%=txtLogin.ClientID %>').val())" />

<asp:CustomValidator runat="server"
ID="cvLoginValidator"
ClientValidationFunction="ValidateLoginExists"
ForeColor="Red" ErrorMessage="Login also exists"
ControlToValidate="txtLogin" />
</div>

此代码仅在表单提交时正常工作,但在 onBlur 时不正常。如何在 onBlur 事件中调用 ValidateLoginExists

最佳答案

您的 CustomValidator 中缺少 EnableClientScript="true"。不确定这是否是问题所在,因为我从未排除过它。我回家后会试试看。

关于javascript - asp.net ajax - 导致验证 onBlur 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6730173/

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