-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
257 lines (232 loc) · 11.7 KB
/
index.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Force latest IE rendering engine or ChromeFrame if installed -->
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
<meta charset="utf-8">
<title>jQuery File Upload Demo - Basic version</title>
<!-- Bootstrap styles -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Generic page styles -->
<link rel="stylesheet" href="css/style.css">
<!-- CSS to style the file input field as button and adjust the Bootstrap progress bars -->
<link rel="stylesheet" href="css/jquery.fileupload.css">
</head>
<body>
<div class="container">
<h1>PAN Card Image Upload</h1>
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="glyphicon glyphicon-plus"></i>
<span>Select PAN...</span>
<!-- The file input field used as target for the file upload widget -->
<!--input id="fileupload" type="file" name="files[]" multiple-->
<input id="fileupload" type="file" name="files">
</span>
(Support File:: pdf, tif/tiff, jpg/jpeg, bmp, gif) (Size: 5MB)
<!--Pre-requisite:: Set files/thumbnail folder's permission 777-->
<br>
<br>
<!-- The global progress bar -->
<div id="progress" class="progress">
<div class="progress-bar progress-bar-success"></div>
</div>
<div id="msg" class="msg"></div>
<!-- The container for the uploaded files -->
<!--div id="files" class="files"></div-->
<br>
<form action="" method="post">
Office name:<br>
<input type="text" name="office" value="">
<br>
Address:<br>
<input type="text" name="address" value="">
<br><br>
<input type="submit" value="Submit" id="sbmtBttn">
</form>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="js/vendor/jquery.ui.widget.js"></script>
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="https://blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="https://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="js/jquery.fileupload.js"></script>
<!-- The File Upload processing plugin -->
<script src="js/jquery.fileupload-process.js"></script>
<!-- The File Upload image preview & resize plugin -->
<script src="js/jquery.fileupload-image.js"></script>
<!-- https://github.com/blueimp/jQuery-File-Upload/wiki/Options -->
<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
/*
First, strict mode makes it impossible to accidentally create global variables. In normal JavaScript mistyping a variable in an assignment creates a new property on the global object and continues to "work" (although future failure is possible: likely, in modern JavaScript). Assignments which would accidentally create global variables instead throw in strict mode:
*/
'use strict';
// Change this to the location of your server-side upload handler:
var url = 'server/index.php';
$('#fileupload')
.bind('fileuploadprocessstart', function (e) {
/* ... */
//$('#fileupload').addClass('btn btn-primary').prop('disabled', true);
$('#fileupload').prop('disabled', true);
$('#progress .progress-bar').css('width', '0%');
})
.bind('fileuploadprocess', function (e, data) {
/* ... */
$('#msg').html('Uploading PAN Image...');
})
.bind('fileuploadprocessdone', function (e, data) {
/* ... */
$('#msg').html('Processing PAN Image...');
})
.bind('fileuploadprocessfail', function (e, data) {
/* ... */
//$('#fileupload').prop('disabled', false);
$('#msg').html('Uploading PAN Image Fail!');
})
.bind('fileuploadprocessalways', function (e, data) {
/* ... */
})
.bind('fileuploadprocessstop', function (e) {
/* ... */
})
.fileupload({
url: url,
dataType: 'json',
acceptFileTypes: /(\.|\/)(pdf|tiff?|jpe?g|bmp|gif)$/i,
maxFileSize: 500000, //5MB
// Enable image resizing, except for Android and Opera,
// which actually support image resizing, but fail to
// send Blob objects via XHR requests:
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator && navigator.userAgent),
imageMaxWidth: 1000,
imageMaxHeight: 1000,
imageCrop: false, // Force cropped images
//image_library: 1,
//imageVersions :{
// maxWidth : 200,
// maxHeight : 200
//},
done: function (e, data) {
console.log(data.result.files)
$.each(data.result.files, function (index, file) {
if(typeof file.error === "undefined") {
if(file.panData.status) {
$('#msg').html('Processed PAN Card Image/File successfully!');
var lines = [];
$.each(file.panData.text.split(/\n/), function(i, line){
if(line){
var pattern = /(\b[A-Z]{2}[A-Z0-9 ]+\b)|((3[01]|[12][0-9]|0[1-9])([\/]|[-]|[A-Z0-9])(1[0-2]|0[1-9])([\/]|[-]|[A-Z0-9])[0-9]{4})|Permanent Account Number/;
if(pattern.test($.trim(line))){
lines.push($.trim(line));
}
}
});
//console.log(lines);
//New PAN Card Check
var indexPANValue = $.inArray( "Permanent Account Number", lines );
var indexITDValue = $.inArray( "INCOME TAX DEPARTMENT", lines );
//Old PAN Card Check
var indexOLDPANValue = $.inArray( "/PERMANENT ACCOUNT NUMBER", lines );
if(indexPANValue !== -1 || indexITDValue !== -1){ //New PAN Card Image
//Person Name
var personName = lines[indexPANValue-3];
var pattern = /[a-z0-9']+/;
if(pattern.test(personName)){
console.log(personName+" (Not validate)");
} else {
console.log(personName);
}
//Father Name
var fatherName = lines[indexPANValue-2] ;
var pattern = /[a-z0-9']+/;
if(pattern.test(fatherName)){
console.log(fatherName+" (Not validate)");
} else {
console.log(fatherName);
}
//DOB
var dateOfBirth = lines[indexPANValue-1] ;
var pattern = /((3[01]|[12][0-9]|0[1-9])([\/]|[-])(1[0-2]|0[1-9])([\/]|[-])[0-9]{4})/;
if(pattern.test(dateOfBirth)){
console.log(dateOfBirth);
} else {
console.log(dateOfBirth+" (Not validate)");
}
//PAN Number
var panNumber = lines[indexPANValue+1] ;
var pattern = /[A-Z]{5}[0-9]{4}[A-Z]{1}/;
if(pattern.test(panNumber) && panNumber.length == 10){
console.log(panNumber);
} else {
console.log(panNumber+"(Not validate)");
}
$('#fileupload').prop('disabled', false);
} else if (indexOLDPANValue !== -1){ //Old PAN Card Image
//PAN Number
var panNumber = lines[indexOLDPANValue+1] ;
var pattern = /[A-Z]{5}[0-9]{4}[A-Z]{1}/;
if(pattern.test(panNumber) && panNumber.length == 10){
console.log(panNumber);
} else {
console.log(panNumber+"(Not validate)");
}
//Person Name
var personName = lines[indexOLDPANValue+3];
var pattern = /[a-z0-9']+/;
if(pattern.test(personName)){
console.log(personName+" (Not validate)");
} else {
console.log(personName);
}
//Father Name
var fatherName = lines[indexOLDPANValue+6] ;
var pattern = /[a-z0-9']+/;
if(pattern.test(fatherName)){
console.log(fatherName+" (Not validate)");
} else {
console.log(fatherName);
}
//DOB
var dateOfBirth = lines[indexOLDPANValue+8] ;
var pattern = /((3[01]|[12][0-9]|0[1-9])([\/]|[-])(1[0-2]|0[1-9])([\/]|[-])[0-9]{4})/;
if(pattern.test(dateOfBirth)){
console.log(dateOfBirth);
} else {
console.log(dateOfBirth+" (Not validate)");
}
$('#fileupload').prop('disabled', false);
} else {
$('#fileupload').prop('disabled', false);
$('#progress .progress-bar').css('width', '0%');
$('#msg').html('Take re-snapshot and then upload or scan n upload PAN again');
}
} else {
$('#fileupload').prop('disabled', false);
$('#progress .progress-bar').css('width', '0%');
$('#msg').html(file.panData.error);
}
} else {
$('#fileupload').prop('disabled', false);
$('#progress .progress-bar').css('width', '0%');
$('#msg').html('Fail to upload File...');
}
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css('width', progress + '%');
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>
</body>
</html>