0

I am using Regular Expression validator with file upload (Asp.Net) control in-order to restrict the files uploaded. My regular expression is as follows:

^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.wmv|.avi|.mpeg|.MPEG|.mp4|.MP4|.flv|.f4v)$

It gives error message of the validator even after uploading the right file in Firefox. But it works fine in IE.

Any one please help me providing a browser compatible way to validate my file upload control.

1
  • Can you provide some examples of good and bad strings? I can't tell what that regex is supposed to do. Commented Sep 15, 2010 at 5:18

1 Answer 1

1

t does not work with Firefox v3.x because it does not allow JavaScript to get full path name from the file input field and this particular regular expression expects to see full path name.

Use javascript to do the validation instead of regular expression validator.

var fileName = fupID.value; var ext = fileName.substring(fileName.lastIndexOf('.') + 1);

        if (ext == "wmv" || ext == "WMV" || ext == "avi" || ext == "AVI" || ext == "mp4" || ext == "MP4" || ext == "flv" || ext == "FLV" || ext == "F4V" || ext == "f4v" || ext=="mpg" || ext=="MPG" || ext=="mpeg" || ext=="MPEG" || ext=="mov" || ext=="MOV") {
     // do required code logic here

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.