I used below script to validate file extension but if file name has any special character so it's not allowing user to select file i want only extension validation file name could be anything.
<script language="javascript" type="text/javascript">
$(function () {
$('[id*=fubanner]').change(function () {
if (typeof (FileReader) != "undefined") {
var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/;
$($(this)[0].files).each(function () {
var file = $(this);
if (regex.test(file[0].name.toLowerCase())) {
var reader = new FileReader();
reader.onload = function (e) {
$('[id*=imgbanner]').attr("src", e.target.result).attr("style", "");
}
reader.readAsDataURL(file[0]);
} else {
alert(file[0].name + " is not a valid image file.");
return false;
}
});
} else {
alert("This browser does not support HTML5 FileReader.");
}
});
});
</script>