.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

File extension validation in textbox in windows form,c#

Posted By: Jayakumar     Posted Date: March 18, 2010    Points:2   Category :Windows Application

i have inserting a column in a table called as pathstring which contains song names ("oruvan.mp3").

i am entering this value to table by textbox. i have to vallidate this textbox for ".mp3" extension. while user enters as only "oruvan" then it should throw error.

how to validate this (substring concept)..


Author: Lalij Mer             
Posted Date: March 18, 2010     Points: 5   

you can also achieve this using Java Script

// You can specify the file type in the code "valid_extensions = /(.doc|.pdf)$/i;" .
//If you want to add .docx supprt simply add |.docx (ex:(.doc|.pdf |.docx| .your-extension) )

var valid_extensions = /(.doc|.pdf)$/i;
function CheckExtension(fld)
if(fld.value) {
if (valid_extensions.test(fld.value)){
return true;
} else {
return false;
} else {
return true;

Please Check my answer if you help....
Thank You...

Author: Jayakumar             
Posted Date: March 18, 2010     Points: 5   

hi lalit

we can use it for windows application 3.5 with c#.

how to validate a textbox with errorprovider control.

on keypress event of textbox, we can use it...


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend