"KTP INA Verification with date"
Bootstrap 3.0.0 Snippet by elkhunsu

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
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<form class="form-horizontal application-form">
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>
<!-- Multiple Radios -->
<div class="form-group">
<label class="col-md-4 control-label" for="radios">Multiple Radios</label>
<div class="col-md-4">
<div class="radio">
<label for="gender1">
<input type="radio" name="radios" id="gender1" value="male" checked="checked">
MALE
</label>
</div>
<div class="radio">
<label for="gender2">
<input type="radio" name="radios" id="gender2" value="female">
FEMALE
</label>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="identification_number">KTP</label>
<div class="col-md-5">
<input id="identification_number" name="identification_number" type="text" placeholder="ktp number" class="form-control input-md" required="" data-odd>
<span class="help-block">Input KTP number</span>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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
$('.application-form').validator({
custom:{
'odd' : function($el){
var matchValue = $el[0].value // foo
return ktpValidator(matchValue);
}
}
}).on('submit', function(){
if (tindakan.isDefaultPrevented()) {
//prevent from submission
} else {
alert('sukses');
}
});
function ktpValidator(matchValue){
var ktpVal = $("[name='identification_number']").val();
if(ktpVal.length === 16 && ktpVal === matchValue){
var dob = $("[name='date_of_birth']").val().split("/");
var cekDateID = $("input[name='gender']:checked").val() === 'female' ? parseInt(dob[0]) + 40 : dob[0];
var dobResult = String(cekDateID).concat(dob[1], dob[2].slice(2))
var dateKtp = ktpVal.slice(6, 12);
if(dobResult !== dateKtp){
return "Data KTP Anda Tidak Valid";
}
} else {
return "Input KTP 16 Digit Anda";
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: