how to validate file extension and filesizea and filename in javascript

<html>
<head>
<script>
function getSize()
{
    //var myFSO = new ActiveXObject("Scripting.FileSystemObject");
    var filepath = document.upload.file.value;
   
    alert(filepath);
   
    //var thefile = myFSO.getFile(filepath);
//    var size = thefile.size;
//    alert(size + " bytes");
}
</script>
</head>
<body>
<form name="upload">
<input type="file" name="file">
<input type="button" value="Size?" onClick="getSize();">
</form>
</body>
</html>