Below is my code which checks for -b.doc in my selected files of that particular multiple fileuploader my problem is suppos if i choose
200-c.docx,201-C.docx,202.wma and 203.wma with same order it is saying validformat it is working some times and not working some times.
function checkFileExtension() {
var chkFile = document.getElementById('<%= filBaseDoc.ClientID %>');
var label = document.getElementById('<%= lblerrmsg.ClientID%>');
var myfile = chkFile.value;
if (myfile.indexOf("-c.doc") > 0 || myfile.indexOf("-C.DOC") > 0) {
label.innerText = "Valid Format";
}
else {
label.innerText = "Invalid Format";
chkFile.value = "";
}
}
<asp:FileUpload ID="filBaseDoc" runat="server" multiple="multiple" onchange="javascript:return checkFileExtension();"/>
i tried above code but it is not working when i do it multiple times
Moreover i had even tried with if (myfile.indexOf("-c.doc") != -1 || myfile.indexOf("-C.DOC") > != -1) but if i choose the files in
below order it is still saying valid format but it should say invalid format
because in the selected files there is an .mp3 file 400-C.doc,401-c.doc,402-C.doc,403.mp3