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."