Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I have done the following piece of code .
C#
<asp:Label ID="lblUploadW9" runat="server" Text="Upload W-9" /><span class="reqd">*</span>
                  </div>
                  <div class="sxlm">
                      <asp:FileUpload ID="fupUploadW9" runat="server" />
                      <div class="vldx">
                          <asp:Label runat="server" ID="lblUploadW9FileName" Text="" Style="word-break: hyphenate;"></asp:Label>
                           <asp:CustomValidator class="errmsg" ID="cusUploadW9" runat="server" ValidationGroup="grpSupAccData"
                              Display="Dynamic" ClientValidationFunction="validateUploadW9" OnServerValidate="cusUploadW9_ServerValidate" />
                      </div>
                  </div>

the jav ascript is :
JavaScript
function validateUploadW9(source, e)
 {
    var fileName = FSObject.$("[id$=fupUploadW9]")[0].value;
     var fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
     if (fileName == "")
     {
        var length = FSObject.$("[id$=lblUploadW9FileName]").length;
        if (FSObject.$("[id$=lblUploadW9FileName]")[length - 1].innerHTML == "")
         {
            e.IsValid = false;
        }
        else 
        {
            if (fileExtension != ".doc" || ".DOC " || ".txt" || ".docx" || ".DOCX" || ".TXT" || ".xls" || ".xlsx" || ".XLS" || ".XLSX" || ".pdf" || ".PDF")
             {
                 FSObject.$("[id$=cusUploadW9]")[0].innerHTML = "Invalid extension, only .doc, .docx, .txt, .xls, .xlsx, .pdf and .jpg extensions are supported";
                 e.IsValid = false;
             }
             else 
            {
                e.IsValid = true;
            }
        }
    }
    else {
        if (fileExtension != ".doc" || ".DOC " || ".txt" || ".docx" || ".DOCX" || ".TXT" || ".xls" || ".xlsx" || ".XLS" || ".XLSX" || ".pdf" || ".PDF") 
        {
            FSObject.$("[id$=cusUploadW9]")[0].innerHTML = "Invalid extension, only .doc, .docx, .txt, .xls, .xlsx, .pdf and .jpg extensions are supported";
            e.IsValid = false;
        }
        else 
        {
            e.IsValid = true; 
        }
      }
       
 }


everything works fine,but the problem is that on entering invalid file type the message gets displayed wrapped with the file-upload control,I want the message to be displayed at the next line,without using
tag.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900