ASP的CustomValidator没有检测到的文字使用jQuery自动完成变更 [英] ASP CustomValidator doesn't detect text changed with JQuery autocomplete

查看:160
本文介绍了ASP的CustomValidator没有检测到的文字使用jQuery自动完成变更的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个使用ASP.NET的CustomValidator来验证文本字段(客户端)的输入网页。文本字段使用jQuery UI自动完成 - 这是我遇到的问题

I've written a web page that uses an ASP.NET CustomValidator to validate the input of a text field (client side). The text field uses JQuery UI Autocomplete - and this is where I run into problems.

验证器工作得很好。但是在验证失败,用户会得到一个错误消息的情况下,用户将回到文本字段,并输入一个新值 - 通过自动完成插件下做出的选择下跌。现在,当已经选择了新的价值,并在用户离开输入字段,验证code不会再次触发。我怀疑这是因为,由于某种原因,没有检测到该文本被改变,当值从自动完成帮手来了。这是否有意义?

The validator works just fine. But in the event that the validation fails and the user gets an error message, the user will go back to the text field and enter a new value - choosing from the drop down made by the autocomplete plugin. Now when a new value has been chosen and the user leaves the input field, the validation code doesn't fire again. I suspect that it is because, for some reason, it is not detected that the text was changed, when the value came from the autocomplete helper. Does that make sense?

有谁知道我怎么能强迫领域通过的CustomValidator验证,当用户从外地删除焦点?

Does anyone know how I can force the field to validate via the CustomValidator when the user removes focus from the field?

继承人的的CustomValidator:

Heres the CustomValidator:

<asp:CustomValidator EnableClientScript="True" runat="server" ControlToValidate="tbInput"
                    ID="inputCustomValidator" ClientValidationFunction="validateFunction" ErrorMessage="Not valid"
                    Display="Dynamic" ValidationGroup="ValidationGrp1" />

这就是所谓的JavaScript是不感兴趣 - 因为它不会被调用。这就是我想达到的目标。

The javascript that is called is not interesting - since it is not being called. That is what I want to achieve.

推荐答案

我发现了一个办法做到这一点。在JavaScript我添加了一个模糊()函数,我想验证元素,并取得该功能触发Page_ClientValidate('validationGroupName')。这是新的给我一个功能。

I found a way to do this. In javascript I added a blur() function to the element I wanted to validate and made that function trigger Page_ClientValidate('validationGroupName'). A functionality that was new to me.

$('.elementToValidate').blur(function () {
Page_ClientValidate('ValidationGrp1');
});

这篇关于ASP的CustomValidator没有检测到的文字使用jQuery自动完成变更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆