For image upload , This is my code,
What is the error, its not checking in else part
if(!$('#upload').val())
{
alert('Upload Your Photo');
$('#upload').focus();
return false;
}
else{
$('input[type=file]').change(function () {
var val = $(this).val().toLowerCase();
var regex = new RegExp("(.*?)\.(jpg|jpeg|txt|png|docx|gif|doc|pdf|xml|bmp|ppt|xls)$");
if(!(regex.test(val)))
{
$(this).val('');
alert('Unsupported file');
}
});
}