Page 1 of 1

how is regular expression causing error?

Posted: Mon Aug 23, 2004 3:31 pm
by voltrader
I'm in process of validating photo file type suffixes using js.

The regex I dug up is:
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*.*))+\.(jpg|JPG|png|PNG|gif|GIF)$

It doesn't work when I test for it using:

Code: Select all

var regex = ^((їa-zA-Z]:)|(\\{2}\w+)\$?)(\\(\wї\w ]*.*))+\.(jpg|JPG|png|PNG|gif|GIF)$;

if(photo.value !='' && !regex.test(photo.value))
{
alert ("we only support .jpg, .png, .gif");
return false;
}
I located the error: it's in the regex. If I comment it out, the script executes.

Could it be the squigglies?

Posted: Mon Aug 23, 2004 3:53 pm
by feyd

Code: Select all

var regex = /blahblbhalbah/;

[SOLVED]

Posted: Mon Aug 23, 2004 3:58 pm
by voltrader
Thanks (yet again)