Checking file extension/type to be Excel or CSV


I am using Axure 9.

I have used text box for simulating file upload, what I want is to show a message to the user if the chosen file is not an Excel or CSV file.

how can I do that. Please help. Do I have to check the file extension on LostFocus or MouseClick, how could that be done

You can use a Lost Focus interaction to check the text on the widget itself, then use that to show, hide or change the text of an error message. I’ve tested this and it works. You can use a ‘contains’ case to check for specific file extensions, so like ‘contains xls’ or ‘contains xlsx’ or ‘contains csv’.

This will break if your filename has a file format in it (like csv.jpg) but should be good enough for a mockup.

1 Like

You can improve this conditional logic by testing if the text contains “.csv”. For even more reliability/accuracy, test only the last several characters of the text–whatever the file extension(s) might be, as in, IF [[LVAR1.slice(-4)]] contains ".csv" or IF [[LVAR1.slice(-5)]] contains ".xlsx", where LVAR1 is a local variable pointing to the text of your widget. The function, slice(N) returns the first N characters from a string and slice(-N) returns only the last N characters from a string.

  • Just be sure to select “Match Any” in the upper-right of the condition builder dialog if you need to test for an occurrence of multiple possible file extensions.