TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Java Script Validation
Joginder Banger
Nov 28
2014
Code
995
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
When we are upload any image on server. Server Throw the Error Image format can't be accept. You can check the Extension of image both way one is JavaScript and another is C#. In this code we are learning how to check format.
You can below code Value is a filename of image with extension.
var
filelength = parseInt(value.length) - 4;
var
fileext = value.substring(filelength,filelength + 4);
if
(fileext.toLowerCase()!=
'.gif'
&& fileext.toLowerCase() !=
'.jpg'
&& fileext.toLowerCase() !=
'jpeg'
&&
fileext.toLowerCase() !=
'bmp'
&&
fileext.toLowerCase() !=
'png'
)
return
false
;
Java Script validation code