RegularExpressionValidator for File Upload not working in Firefox, works fine in IE and Chrome

Filed in .Net Leave a comment

I want to validate the file extension before uploading. To validate the file extention I was using below Expression

“^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.doc|.docx|.xls|.xlsx|.pdf|.jpg|.JPG|.jpeg|.gif|.png|.bmp)$”

Above expression was not working in Firefox whereas works fine in IE and Chrome. After some Google searching I found below expression which works fine in above mention three browsers

“(.*\.([dD][oO][cC]|[dD][oO][cC][xX]|[xX][lL][sS]|[xX][lL][sS][xX]|[gG][iI][fF]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[bB][mM][pP]|[pP][nN][gG]|[pP][dD][fF])$)”

Below is the link from where I found the expression

http://stackoverflow.com/questions/810541/file-upload-with-regularexpressionvalidator-not-working-with-firefox-only-ie

TOP