check filename file upload

tvdgreft 06 Oct, 2015
I want to check the extension of a filename in the fileld " file field " (name = file) before the submit button is clicked on.
I made the following javascript:
function CheckExtension(file)
{
  var extension = file.substr( (file.lastIndexOf('.') +1) );
  if(extension != "ly" && extension != "xml" && extension != "mxl")
  {
       alert("Verkeerde bestandextensie");
       return false;
   }
   return true;
}

But it does not work. I think because file is not the filename given in the field.

Greetings Theo
GreyHead 07 Oct, 2015
Hi Theo,

There are a couple of possible solutions in this StackOverFlow thread. You can also add an 'accep' attribute in the element Extra Params box that might help.

Bob
This topic is locked and no more replies can be posted.