-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext nand size validation.html
66 lines (56 loc) · 1.51 KB
/
ext nand size validation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE HTML>
<html>
<head>
<script>
var allowedExtensions = {
'.doc' : true,
'.DOC' : true,
'.DOCX' :true,
'.docx' :true,
'.pdf':true,
'.PDF' :true,
'.TXT' :true,
'.txt':true
};
function checkExtension(filename)
{
var match = /\..+$/;
var ext = filename.match(match);
if (allowedExtensions[ext])
{
return true;
}
else
{
alert("File must be DOCX or DOC or PDF or TXT");
//will clear the file input box.
location.reload();
return false;
}
}
function chkSize()
{
var inputFile = document.getElementById('file1');
for (var i = 0; i < inputFile .files.length; i++)
{
var file = inputFile .files[i];
if ('size')
{
var sz=file.size/(1024*1024);
//RESTRICTING UPLOAD FILE SIZE TO 1MB
if(sz >=1)
{
alert('Document is not UPLOADED. Maximum file size is restricted to 1MB.Please try again Uploading other document!!');
location.reload();
return false;
}
}
}
}
</script>
</head>
<body>
<input type="file" value="choose a file" id="file1" onchange="checkExtension(this.value);">
<input type="submit" value="submit" onclick="chkSize();">
</body>
</html>