how is regular expression causing error?
Posted: Mon Aug 23, 2004 3:31 pm
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:
I located the error: it's in the regex. If I comment it out, the script executes.
Could it be the squigglies?
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;
}Could it be the squigglies?