Last post Jun 20, 2014 06:53 AM by UserTSS
Member
7 Points
37 Posts
Jun 20, 2014 12:17 AM|UserTSS|LINK
Hiii frndsssss... Here m doing file uploading.... i want to upload only .CSV file, so i need regular expression... please... :)
Thank You
asp.net vb.net
All-Star
50841 Points
9895 Posts
Jun 20, 2014 01:26 AM|A2H|LINK
You can use the below regular expression to validate the file extension.
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.csv|.CSV)$
Complete Code:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script> function validate() { var uploadcontrol = document.getElementById('<%=FileUpload1.ClientID%>').value; //Regular Expression for fileupload control. var reg = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.csv|.CSV)$/; if (uploadcontrol.length > 0) { //Checks with the control value. if (reg.test(uploadcontrol)) { return true; } else { //If the condition not satisfied shows error message. alert("Only .csv files are allowed!"); return false; } } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return validate();" /> </div> </form> </body> </html>
Source URL
Jun 20, 2014 06:53 AM|UserTSS|LINK
This expression is working for me....
"^.*\.(csv)$"
Member
7 Points
37 Posts
Regular Expression for CSV file ...???
Jun 20, 2014 12:17 AM|UserTSS|LINK
Hiii frndsssss...
Here m doing file uploading....
i want to upload only .CSV file, so i need regular expression... please... :)
Thank You
asp.net vb.net
All-Star
50841 Points
9895 Posts
Re: Regular Expression for CSV file ...???
Jun 20, 2014 01:26 AM|A2H|LINK
You can use the below regular expression to validate the file extension.
Complete Code:
Source URL
asp.net vb.net
Aje
My Blog | Dotnet Funda
Member
7 Points
37 Posts
Re: Regular Expression for CSV file ...???
Jun 20, 2014 06:53 AM|UserTSS|LINK
This expression is working for me....
"^.*\.(csv)$"
asp.net vb.net