I have button and file upload control in the page, i want to enable or disable button based on value of file upload control. if the file upload does not have selected file then button still disable.
The code is working fine however if you choose the file then button able (correct behaviour) then you click file upload control but this time you want to click cancel but the the button is not disable.
function enableButton() {
var a = document.getElementById("<%=file_upload.ClientID%>")
if (a == 0) {
document.getElementById("<%=btnAdd.ClientID%>").disabled = true;
}
else {
document.getElementById("<%=btnAdd.ClientID%>").disabled = false;
}
}
<asp:FileUpload ID="file_upload" runat="server" AllowMultiple="true" maxLength="10" accept="text/plain" Enabled="false" CssClass="cssFileUpload" onchange="enableButton()"/>
<asp:Button ID="btnAdd" runat="server" Text="Add Files" onclick="btnAdd_Click" Enabled="false" />