0

I'm currently making a TestForm but I've run into some issues. I have 2 textboxes as follows:

<asp:textbox id="VATNbrUser" 
                style="Z-INDEX: 160; POSITION: relative; width: 319px; top: 0px; left: 0px;" runat="server" 
                MaxLength="35" ToolTip="Max. 35 posities" >
<asp:textbox id="AliasUser" 
                style="Z-INDEX: 160; POSITION: relative; width: 319px; top: 0px; left: 0px;" runat="server" 
                MaxLength="35" ToolTip="Max. 35 posities" >

Right now, if i want to enable a button if both textboxes are not empty. So I made a function:

    function ControleInput() {

        document.getElementById('WriteData').disabled = true;
        var allFields = true;

        //Controleren op de aanwezigheid van een alias
        if (!document.getElementById('AliasUser').value.length > 0) {
            allFields = false;
        }

        //Controleren op de aanwezigheid van een BTW-Nummer
        if (!document.getElementById('VATNbrUser').value.length > 0)
        { allFields = false; }
        //Controleren op de aanwezigheid van een afkorting

        if (allFields) {
            document.getElementById('<%=WriteData.ClientID %>').disabled = false;
        }

}

which i assign to my textboxes using the following code:

    VATNbrUser.Attributes.Add("onkeydown", "ControleInput()")
    AliasUser.Attributes.Add("onkeydown", "ControleInput()")

This code works when the user types data into a Textbox. Yet it doesn't work when the user presses CTRL+V or Right-Click followed by Paste. What am i doing wrong?

I've tried the following links but to no avail:

detect pasted text with CTRL+V

detect CTRL+V using JS

ASP.NET Event: Ontextchanged

ASP.NET: TextChanged

Community
  • 1
  • 1
User999999
  • 2,500
  • 7
  • 37
  • 63

0 Answers0