Sunday 6 January 2013

jQuery to Validate File Upload Extension in File Upload Control



<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$('#<%=fileupload1.ClientID %>').change(function() {
var fileExtension = ['jpeg', 'jpg', 'png', 'gif', 'bmp'];
if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
alert("Only '.jpeg','.jpg', '.png', '.gif', '.bmp' formats are allowed.");
}
})
})
</script>

No comments:

Post a Comment