Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use regular expression validator for mu file uploader control....my code is below

ASP.NET
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Only .doc , .docx or .txt files" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.doc|.docx|.txt)$" ControlToValidate="ContractFile" ValidationGroup="OwnerSignUp">



but it is not working...plz help me to validate .doc,.docx and txt for file uploader

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 11-Oct-12 21:36pm
v2
Comments
Zoltán Zörgő 12-Oct-12 3:24am    
What is the "some error" you got?
Member 9492907 12-Oct-12 3:26am    
Not an error but its validation is not working...I can't upload anything

1 solution

Try a simpler expression:
^.*?\.(doc|docx|txt)$
 
Share this answer
 
Comments
Member 9492907 12-Oct-12 3:42am    
Thank you it is working.....can u plz give me the validation for jpeg and pdf...
OriginalGriff 12-Oct-12 3:43am    
Um.
Are you serious?
Member 9492907 12-Oct-12 3:44am    
but when i use the ValidationExpression="^.*?\.(docx|pdf|jpeg)$"..it is not accepting the jpeg filess
OriginalGriff 12-Oct-12 4:05am    
And the extension for a JPEG file is?
myworddocument.DOC is a Word Document
myportabledocument.PDF is adobe Portable Document Format
And is an image file myimage.JPEG? Or something slightly different?
Member 9492907 12-Oct-12 4:08am    
I got the answer..ValidationExpression="^.*?\.(docx|pdf|jpg)$.....thank u sooo much for the help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900