Jump to content

Regular Expressions and Firefox


K_Drive

Recommended Posts

Hello.Has anyone worked with Firefox and regular expressions? Does Firefox handle things differently in any way?Here is what is going on:I am working on a web app that uses this regular expression for validation on a web page.This expressoin is supposed to check to see if a user is browsing and retreiving a JPG file. ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.jpg|.JPG)$" It works in IE. When I user browses to a JPG file, they can upload it. But, when a user tries to upload a JPG file in Firefox, it triggers the validation message and won't allow them to upload it.Here is an example file path from the app. There are no spaces before or after the path. C:\_myQTownApp\ConsumerApp\ConsumerWeb\images\Added_Images\sweatshirt.jpgAny ideas?Thanks,K_Drive

Link to comment
Share on other sites

Hard to say out of context. What I really don't understand is why your expression is so complicated.str.match (/.jpg$/i)This should do everything you need to know on the client end. You're validating the extension, not the whole path.I assume your server script performs actual validation of the file's mime-type?

Link to comment
Share on other sites

Hard to say out of context. What I really don't understand is why your expression is so complicated.str.match (/.jpg$/i)This should do everything you need to know on the client end. You're validating the extension, not the whole path.I assume your server script performs actual validation of the file's mime-type?
DD: Thanks for the reply. It's not my expression. I'm just the tester/fixer/other.I will send this to my manager. He's the one who understands the REs. I am just an RE newbie.K_Drive
Link to comment
Share on other sites

By the way the regular expression delimiter in JavaScript is the forward slash /, not the quotation mark ". Try that.

Link to comment
Share on other sites

Another thing to keep in mind is that Firefox and IE differ in their implementations of the input type="file" element.Consider this:

<html><body><input type="file" onchange="alert(this.value)" /></body></html>

Using your file path as an example (C:\_myQTownApp\ConsumerApp\ConsumerWeb\images\Added_Images\sweatshirt.jpg):Firefox alerts:sweatshirt.jpgIE alerts:C:\_myQTownApp\ConsumerApp\ConsumerWeb\images\Added_Images\sweatshirt.jpg

Link to comment
Share on other sites

Everyone:Thanks you for all the replies. After further research, it appears that the problem isn't with the expression. It is an exact duplicate of one from the MSDN website with only the file extensions changed.It turns out that the problem is that the ASP.NET client-side validation doesn't work well with non-MS browers. Here is one article about it:http://aspnet.4guysfromrolla.com/articles/051204-1.aspxThanks to all who responded.K_Drive

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...