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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manoj Maharana
NA
362
126.8k
how to add a validation in fileuploader during onchange
Aug 29 2016 4:48 AM
how to add a validation in fileuploader during fileuploader onchange method it will accept only images with image preview???
I have a fileuploader in asp.net c#..I have already made a javascript function during fileuploader onchange method for image preview...
Here is my code for fileuplader
<asp:FileUpload ID="fileuploadimages" onchange="showimagepreview(this)" runat="server" />
<img src="" id="imgprvw" height="200">'
Here is my javascript code for imagepreview
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function showimagepreview(input) {
debugger
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function (e) {
$('#imgprvw').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
}
</script>
Every thing is working fine..My problem is that i want to add a validation that
uploaded file only accept images not other file..how to modified my javasscript code that it will only accept images..if we will choose other file then fileuploader will become empty...can any one help me please??
Reply
Answers (
8
)
How to marge to sp result in MVC???
drop down list select value bind in data list .net c#