RSS

Validate image file name using Regular Expression

29 Sep

Validate the image, whether the png or jpeg using,

function validateFileExtension(fileName) {        
 var exp = /^.*\.(jpg|jpeg|gif|JPG|png|PNG)$/;         
 return exp.test(fileName);  
}

This method will return true, if the file name contain extension .jpeg or .png.

 
Leave a comment

Posted by on September 29, 2011 in General, Javascript, Strings

 

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: