maratg
asked on
RegularExpressionValidator fires incorrectly in Firefox 3.0 and Safari
I'm writing a vs.net 2005 web application. I'm asking users to upload an image file, using the asp:FileUpload element. I have a RegularExpressionValidator that checks the path of the uloaded file to determine if it's an image based on the file extension.
Here is the code for the validator:
<asp:RegularExpressionVali dator ID="CustomValidator1" runat="server" ErrorMessage="*"
ControlToValidate="element thumbnailu pload" ValidationExpression="^(([ a-zA-Z]:)| (\\{2}\w+) \$?)(\\(\w [\w].*))(. jpg|.JPG|. gif|.GIF|. jpeg|.JPEG |.bmp|.BMP |.png|.PNG )"></asp:R egularExpr essionVali dator>
It works well in IE, however it fires incorrectly in Firefox 3.0 and Safari (the file has the correct image extentsion). Please help. Thanks in advance.
Here is the code for the validator:
<asp:RegularExpressionVali
ControlToValidate="element
It works well in IE, however it fires incorrectly in Firefox 3.0 and Safari (the file has the correct image extentsion). Please help. Thanks in advance.
ASKER
Thanks, but this does not address the core issue as to why the validator is behaving differently in different browsers. Although we may try to use your solution in the interim.
Are you sure your regular expression is correct? I tested it in Firefox and Internet Explorer 7.0. Although IE7 allowed the postback and didn't fire the validator, the page didn't pass server-side validation and the error text displayed after the postback.
I suspect the behaviour you are seeing in Firefox and Safari is actually the correct one.
I suspect the behaviour you are seeing in Firefox and Safari is actually the correct one.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
NazoUK,
thanks, that worked like a charm.
thanks, that worked like a charm.
I guess you could turn off the "client side" feature... by using EnableClientScript = False
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.enableclientscript.aspx