See the changes code
function fileCheck(obj)
{
var fileUploadPath = obj.value;
var fileSize = obj.files[0].size;
var extension = fileUploadPath.substring(fileUploadPath.lastIndexOf('.') + 1).toLowerCase();
if (extension == "gif" || extension == "png" || extension == "bmp" || extension == "jpeg" || extension == "jpg")
{
}
else
{
alert("Photo only allows file types of GIF, PNG, JPG, JPEG and BMP.");
Clear();return false;
}
if (fileSize > 1024)
{
alert("Photo size should not exceeds 1 MB");
Clear();
return false;
}
Declare Clear function
function Clear()
{
var clrFile = document.getElementById("FileUpload1");
clrFile.select();
var clr=clrFile.createTextRange();
clr.execCommand('delete');
clrFile.focus();
}