javascript 자바스크립트 차량번호판 유효성 체크
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 |
function checkPlate (value){
var NSValue = value.replace(/ /gi, "");
var region = NSValue.substring(0, 2);
var checkRegion = "서울,부산,대구,인천,대전,광주,울산,제주,경기,강원,충남,충북,전남,전북,경남,경북";
var arrCheckRegion = checkRegion.split(',');
for(var i = 0; i < arrCheckRegion.length; i++){
if(region==arrCheckRegion[i]){
NSValue = NSValue.substring(2, NSValue.length);
break;
}
}
var typeOfCar = Number(NSValue.substring(0, 2));
if(isNaN(typeOfCar) || typeOfCar <= 0){
return false;
}
var use = NSValue.substring(2, 3);
var checkUse = "가,나,다,라,마,"
+"거,너,더,러,머,버,서,어,저,"
+"고,노,도,로,모,보,소,오,조,"
+"구,누,두,루,무,부,수,우,주,"
+"바,사,아,자,"
+"배,"
+"허,하,호,"
+"국,합,육,해,공";
var arrCheckUse = checkUse.split(',');
var resultUse = 0;
for(var j = 0; j < arrCheckUse.length; j++){
if(use==arrCheckUse[j]){
resultUse = 1;
break;
}
}
if(resultUse == 0) return false;
var serialNumber = NSValue.substring(3, value.length);
if(isNaN(serialNumber) || serialNumber < 1000){
return false;
}
return true;
}
|
cs |
댓글