本文介绍了如何调用JS功能,在数据选择上述<输入类型="文本">从自动完成列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框的形式:
无论值由打字改变,呈现出由Key preSS事件警报消息,但如果使用自动完成表是在IE中启用,然后它不工作,每当用户双击并从可能的条目列表中选择文本,用户之前,键入

I have a form with a text box:wherever value changed by typing, showing alert message by KeyPress event, but it does not work if "Use AutoComplete for Form" is enable in IE and then whenever user double click and select text from a list of "possible entries, user have typed before".

推荐答案

使用客户端的事件这一目的:

Use the client-side "onpropertychange" event for this purpose:

下面是两个标准和DevEx preSS解决方案(它看起来像你正在使用它)文本框:

Here is the solution for both the standard and DevExpress (it looks like you are using it) textboxes:

<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
    //DevExpress ASPxTextBox
    function OnInit(s, e) {
        var inputElement = s.GetInputElement();
        ASPxClientUtils.AttachEventToElement(inputElement, "propertychange", function (event) {
            if (event.propertyName === "value") {
                alert("Value Changed");
                alert(event.srcElement.value);
            }
        });
    }

    //Standard Input
    $(document).ready(function () {
        var inputElement = document.getElementById("txt");
        //var inputElement = document.getElementById('<%=txt.ClientID%>');
        inputElement.attachEvent("onpropertychange", function (event) {
            if (event.propertyName === "value") {
                alert("Value Changed");
                alert(event.srcElement.value);
            }
        });
    });
</script>

<dx:ASPxTextBox ID="txtDX" runat="server" Width="170px">
    <ClientSideEvents Init="OnInit" />
</dx:ASPxTextBox>
<br />
<input id="txt" type="text" runat="server" />
<br />
<asp:Button ID="btn" runat="server" Text="Button" />

这篇关于如何调用JS功能,在数据选择上述&lt;输入类型=&QUOT;文本&QUOT;&GT;从自动完成列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 15:46