473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem with regular expression validator on asp.net page

I'm having a problem with a regular expression in conjunction with the
regular expression validator. I am trying to make sure that when a user
browses for a file to upload, it ends in gif, jpeg or jpg. I have the
following expression which validates fine in a .net tester I use and
also a javascript tester. But when I use the following path on the
page, it gives me the error message that I haven't entered a valid
image.

(\.gif|\.jp[e]?g|\.png|\.JP[E]?G|\.GIF|\.PNG)$

C:\Documents and Settings\Geoff\Desktop\mypic.jpg

What am I doing wrong here?

Jul 8 '06 #1
1 2220
In news:11**********************@m79g2000cwm.googlegr oups.com,
vtxr1300 <ca********@hotmail.comwrote:
I'm having a problem with a regular expression in conjunction with the
regular expression validator. I am trying to make sure that when a
user browses for a file to upload, it ends in gif, jpeg or jpg. I
have the following expression which validates fine in a .net tester I
use and also a javascript tester. But when I use the following path
on the page, it gives me the error message that I haven't entered a
valid image.

(\.gif|\.jp[e]?g|\.png|\.JP[E]?G|\.GIF|\.PNG)$

C:\Documents and Settings\Geoff\Desktop\mypic.jpg

What am I doing wrong here?
A regular expression validator requires the regexp to match the whole input
field not just part of it. You are matching only the ending (file
extension). The following will do what you want:

..+(\.gif|\.jp[e]?g|\.png|\.JP[E]?G|\.GIF|\.PNG)$

In fact it will insist on the form filename.ext where ext is validated as
you have it and filename must be at list one character. As it is, it will
accept any character(s) for the name; you may want to change it to match
only characters that are legal in file name.
--
Jim
"Remember, an amateur built the Ark; professionals built the Titanic."
Jul 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
2
by: Nazir | last post by:
Hi I'm using a regular expression validator, but if spaces are entered, it bypasses the validation! I'm using ^{5,100}$
2
by: Dot net work | last post by:
Hello. Say I have a .net textbox that uses a .net regularexpressionvalidator. If the regular expression fails, is it possible to launch a small client side javascript function to do something,...
4
by: | last post by:
Here is an interesting one. Running asp.net 2.0 beta 2. I have a regular expression used in a regex validator that works on the client side in Firefox but not in IE. Any ideas? IE always reports...
2
by: kieran | last post by:
Hi, I am using Visual Studio 2005 and am trying to use a Regular Expression Validator control. I have a drop down list which contains various names, the first one is "Please Select". I want...
2
by: shomun | last post by:
Hi, I am new to regular expression stuffs. I am facing problem while implementing a reg. exp. for a textbox using regular expression validator in ASP page. Requirement: It will take only...
6
by: David | last post by:
I'm having trouble getting the regular expression validator to work with a text box. In this simple example I only want lower case letters to be allowed. So I tried the following and it doesn't...
2
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters....
1
by: durga2005 | last post by:
hi i have a textbox and regular expression validator control .i have placed these control inside update panel. just im validating the textbox with regular expression validator control when i...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.