title: Restrict user for uploading file with Special characters
body: <p>Currently what happening here is, whenever a user uploads a file with some special characters like <em>%, &amp;, #</em>. it gets uploaded and while downloading it gives issues.</p>
  
  <p>So now what I want is, whenever a user start uploading a file it should give him alert message in <strong>JAVASCRIPT</strong> stating that, please upload the file without <strong>special characters</strong> and <strong>SPACES</strong>.</p>
  
  <p>Here is my code for FileUpload:-</p>
  
  <pre><code>&lt;td style="width: 10%;" class="field"&gt;
  &lt;asp:fileupload id="fileUpload" runat="server" width="100%" /&gt;
  &lt;div id="divSText" runat="server" style="display: none"&gt;
      &lt;asp:textbox id="txtSText" runat="server" textmode="MultiLine" width="80%" rows="9"&gt;
                      &lt;/asp:textbox&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Also see the code behind:-</p>
  
  <pre><code>protected void btnSave_Click(object sender, EventArgs e)
  {
      string Datafile = ""; HttpPostedFile PF_File; string Filename = "";
      if (HidFlag.Value == "Add")
      {
          if (Directory.Exists(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/")) == false)
          {
              Directory.CreateDirectory(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/"));
          }
          if (Directory.Exists(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value)) == false)
          {
              Directory.CreateDirectory(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value));
          }
          if (Directory.Exists(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value + "/" + ddlCategory.SelectedValue)) == false)
          {
              Directory.CreateDirectory(Server.MapPath("~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value + "/" + ddlCategory.SelectedValue));
          }
          if (fileUpload.PostedFile.FileName != "")
          {
              PF_File = fileUpload.PostedFile;
              Datafile = fileUpload.FileName;
              Filename = Datafile.Substring(Datafile.LastIndexOf("\\") + 1, Datafile.Length - Datafile.LastIndexOf("\\") - 1);
              PF_File.SaveAs(Server.MapPath((@"~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value + "/" + ddlCategory.SelectedValue + "/" + Filename)));
  
              string str_query = "insert into EMP_ATTACHED_DOCUMENTS(form_id, document_id, category_id, title, descriptions, file_name, file_path, pk1_value, delete_flag, creation_date, created_by) " +
                                        "values('" + Request.QueryString["form_id"] + "', '" + Request.QueryString["document_id"] + "', '" + ddlCategory.SelectedValue + "', '" +
                                         txtTitle.Text + "','" + txtDescription.Text + "','" + Filename + "','" +
                                        Server.MapPath((@"~/Payroll/Masters/FileAttachment/ESS/" + Hid_Empcode.Value + "/" + ddlCategory.SelectedValue + "/" + Filename)) + "','" +
                                        Request.QueryString["empcode"] + "', 'N', getdate(),'" + Request.QueryString["empcode"] + "' )";
              ObjPriDal.ExecuteNonQuery(str_query);
          }
      }
      else if (HidFlag.Value == "Edit")
      {
          ObjPriDal.ExecuteNonQuery("insert into EMP_ATTACHED_DOCUMENTS_H select getdate(), * From EMP_ATTACHED_DOCUMENTS where mkey=" + HidFileID.Value);
          ObjPriDal.ExecuteNonQuery("update EMP_ATTACHED_DOCUMENTS set title='" + txtTitle.Text + "', descriptions='" + txtDescription.Text + "' where mkey=" + HidFileID.Value);
      }
      ClientScript.RegisterStartupScript(this.GetType(), "CloseScript", "document.cookie = 'CAttachid=1'; window.open('FrmCrm_File_Attachment.aspx?form_id=" + Request.QueryString["form_id"] + "&amp;document_id=" + Request.QueryString["document_id"] + "&amp;category_id=" + Request.QueryString["category_id"] + "&amp;empcode=" + Request.QueryString["empcode"] + "&amp;mkey=" + Request.QueryString["mkey"] + "','_self');", true);
  }
  </code></pre>