text: function validate_fileupload(Filename)
  {
      var allowed_extensions = new Array("txt","doc","pdf");
      var file_extension = Filename.split('.').pop().toLowerCase(); // split function will split the filename by dot(.), and pop function will pop the last element from the array which will give you the extension as well. If there will be no extension then it will return the filename.
  
      for(var i = 0; i <= allowed_extensions.length; i++)
      {
          if(allowed_extensions[i]==file_extension)
          {
              return true; // valid file extension
          }
      }
  
      if(Filename.files.length === 0){
          alert("Attachment Required");
          Filename.focus();
  
      return false;
      }
  }
  
  var _validFileExtensions = [".txt", ".docx", ".doc", ".pdf"];
  function Validate(oForm) {
      var arrInputs = oForm.getElementsByTagName("input");
      for (var i = 0; i < arrInputs.length; i++) {
          var oInput = arrInputs[i];
          if (oInput.type == "file") {
              var sFileName = oInput.value;
              if (sFileName.length > 0) {
                  var blnValid = false;
                  for (var j = 0; j < _validFileExtensions.length; j++) {
                      var sCurExtension = _validFileExtensions[j];
                      if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
                          blnValid = true;
                          break;
                      }
                  }
  
                  if (!blnValid) {
                      alert("Sorry, " + sFileName + " is invalid, allowed extensions are: " + _validFileExtensions.join(", "));
                      return false;
                  }
              }
          }
      }
  
      return true;
  }