PageSourceSearch

https://www.aladin.co.kr/js/prototypeUtil.js

js aladin.co.kr collected 2026-09-24 08:28:11 UTC 12,143 bytes, 331 lines download raw bytes

1// JScript 파일
2
3//-----------------------------------------------------------------------------
4// 문자 앞 뒤 공백을 제거 한다.
5//-----------------------------------------------------------------------------
6String.prototype.trim = function() { 
7return this.replace(/(^\s*)|(\s*$)/g, ""); 
8}
9
10//-----------------------------------------------------------------------------
11// 내용이 있는지 없는지 확인하다.
12//
13// @return : true(내용 있음) | false(내용 없음)
14//-----------------------------------------------------------------------------
15String.prototype.notNull = function() {
16return (this == null || this.trim() == "") ? false : true; 
17}
18
19//-----------------------------------------------------------------------------
20// 메일의 유효성을 체크 한다.
21//
22// @return : true(맞는 형식) | false(잘못된 형식)
23//-----------------------------------------------------------------------------
24String.prototype.mail = function() {
25    var em = this.trim().match( /^[_\-\.0-9a-zA-Z\\+]{1,}@[-.0-9a-zA-z]{2,}\.[a-zA-Z]{2,4}$/ );
26return (em) ? true : false;
27}
28
29//-----------------------------------------------------------------------------
30// 주민번호 체크 XXXXXX-XXXXXXX 형태로 체크
31//
32// @return : true(맞는 형식) | false(잘못된 형식)
33//-----------------------------------------------------------------------------
34String.prototype.jumin = function() {
35var num = this.trim().onlyNum();
36if(num.length == 13) {
37num = num.substring(0, 6) + "-" + num.substring(6, 13); 
38}
39else {
40return false;
41}
42num = num.match(/^([0-9]{6})-?([0-9]{7})$/);
43if(!num) return false;
44var num1 = RegExp.$1;
45var num2 = RegExp.$2;
46if(!num2.substring(0, 1).match(/^[1-4]{1}$/)) return false;
47num = num1 + num2;
48var sum = 0;
49var last = num.charCodeAt(12) - 0x30;
50var bases = "234567892345";
51for (i=0; i<12; i++) {
52sum += (num.charCodeAt(i) - 0x30) * (bases.charCodeAt(i) - 0x30);
53}
54var mod = sum % 11;
55return ((11 - mod) % 10 == last) ? true : false;
56}
57
58//-----------------------------------------------------------------------------
59// 사업자번호 체크 XXX-XX-XXXXX 형태로 체크
60//
61// @return : true(맞는 형식) | false(잘못된 형식)
62//-----------------------------------------------------------------------------
63String.prototype.biznum = function() {
64var num = this.trim().onlyNum();
65if(num.length == 10) {
66num = num.substring(0, 3) + "-" + num.substring(3, 5) + "-" + num.substring(5, 10);
67}
68else {
69return false;
70}
71num = num.match(/([0-9]{3})-?([0-9]{2})-?([0-9]{5})/);
72if(!num) return false;
73num = RegExp.$1 + RegExp.$2 + RegExp.$3;
74var cVal = 0;
75for (var i=0; i<8; i++) {
76var cKeyNum = parseInt(((_tmp = i % 3) == 0) ? 1 : ( _tmp == 1 ) ? 3 : 7);
77cVal += (parseFloat(num.substring(i,i+1)) * cKeyNum) % 10; 
78}
79var li_temp = parseFloat(num.substring(i,i+1)) * 5 + '0';
80cVal += parseFloat(li_temp.substring(0,1)) + parseFloat(li_temp.substring(1,2));
81return (parseInt(num.substring(9,10)) == 10 - (cVal % 10)%10) ? true : false;
82}
83
84
85//-----------------------------------------------------------------------------
86// 사업자번호 체크 XXX-XX-XXXXX 형태로 체크
87//
88// @return : true(맞는 형식) | false(잘못된 형식)
89//-----------------------------------------------------------------------------
90String.prototype.biznum2 = function() {
91var num = this.trim();
92num = num.match(/^[0-9]{3}-[0-9]{2}-[0-9]{5}$/);
93return (num) ? true : false;
94}
95
96//-----------------------------------------------------------------------------
97// 전화번호 체크 XXX-XXXX-XXXX 형태로 체크
98//
99// @return : true(맞는 형식) | false(잘못된 형식)
100//-----------------------------------------------------------------------------
101String.prototype.phone = function() {
102var num = this.trim().onlyNum();
103if(num.substring(1,2) == "2") {
104num = num.substring(0, 2) + "-" + num.substring(2, num.length - 4) + "-" + num.substring(num.length - 4, num.length);
105}
106else {
107num = num.substring(0, 3) + "-" + num.substring(3, num.length - 4) + "-" + num.substring(num.length - 4, num.length);
108}
109num = num.match(/^0[0-9]{1,2}-[1-9]{1}[0-9]{2,3}-[0-9]{4}$/);
110return (num) ? true : false;
111}
112
113
114//-----------------------------------------------------------------------------
115// 전화번호 체크 XXX-XXXX-XXXX 형태로 체크
116//
117// @return : true(맞는 형식) | false(잘못된 형식)
118//-----------------------------------------------------------------------------
119String.prototype.phone2 = function() {
120var num=this.trim();
121num = num.match(/^0[0-9]{1,2}-[1-9]{1}[0-9]{2,3}-[0-9]{4}$/);
122return (num) ? true : false;
123}
124
125//-----------------------------------------------------------------------------
126// 핸드폰 체크 XXX-XXXX-XXXX 형태로 체크
127//
128// @return : true(맞는 형식) | false(잘못된 형식)
129//-----------------------------------------------------------------------------
130String.prototype.mobile2 = function() {
131var num = this.trim();
132num = num.trim().match(/^01[016789]{1}-[0-9]{3,4}-[0-9]{4}$/);
133return (num) ? true : false;
134}
135
136//-----------------------------------------------------------------------------
137// 핸드폰 체크 XXX-XXXX-XXXX 형태로 체크
138//
139// @return : true(맞는 형식) | false(잘못된 형식)
140//-----------------------------------------------------------------------------
141String.prototype.mobile = function() {
142var num = this.trim().onlyNum();
143num = num.substring(0, 3) + "-" + num.substring(3, num.length - 4) + "-" + num.substring(num.length - 4, num.length);
144num = num.trim().match(/^01[016789]{1}-[1-9]{1}[0-9]{2,3}-[0-9]{4}$/);
145return (num) ? true : false;
146}
147
148//-----------------------------------------------------------------------------
149// 숫자만 체크
150//
151// @return : true(맞는 형식) | false(잘못된 형식)
152//-----------------------------------------------------------------------------
153String.prototype.num = function() {
154return (this.trim().match(/^[0-9]+$/)) ? true : false;
155}
156
157//-----------------------------------------------------------------------------
158// 영어만 체크
159//
160// @return : true(맞는 형식) | false(잘못된 형식)
161//-----------------------------------------------------------------------------
162String.prototype.eng = function() {
163return (this.trim().match(/^[a-zA-Z]+$/)) ? true : false;
164}
165
166//-----------------------------------------------------------------------------
167// 영어와 숫자만 체크
168//
169// @return : true(맞는 형식) | false(잘못된 형식)
170//-----------------------------------------------------------------------------
171String.prototype.engnum = function() {
172return (this.trim().match(/^[0-9a-zA-Z]+$/)) ? true : false;
173}
174
175//-----------------------------------------------------------------------------
176// 영어와 숫자만 체크
177//
178// @return : true(맞는 형식) | false(잘못된 형식)
179//-----------------------------------------------------------------------------
180String.prototype.numeng = function() {
181return this.engnum();
182}
183
184//-----------------------------------------------------------------------------
185// 아이디 체크 영어와 숫자만 체크 첫글자는 영어로 시작
186//
187// @return : true(맞는 형식) | false(잘못된 형식)
188//-----------------------------------------------------------------------------
189String.prototype.userid = function() {
190return (this.trim().match(/[a-zA-z]{1}[0-9a-zA-Z]+$/)) ? true : false;
191}
192
193//-----------------------------------------------------------------------------
194// 한글만 체크
195//
196// @return : true(맞는 형식) | false(잘못된 형식)
197//-----------------------------------------------------------------------------
198String.prototype.kor = function() {
199return (this.trim().match(/^[가-힣]+$/)) ? true : false;
200}
201
202//-----------------------------------------------------------------------------
203// 숫자와 . - 이외의 문자는 다 뺀다. - 통화량을 숫자로 변환
204
205//
206// @return : 숫자
207//-----------------------------------------------------------------------------
208String.prototype.toNum = function() {
209var num = this.trim();
210return (this.trim().replace(/[^0-9\.-]/g,""));
211}
212
213//-----------------------------------------------------------------------------
214// 숫자 이외에는 다 뺀다.
215//
216// @return : 숫자
217//-----------------------------------------------------------------------------
218String.prototype.onlyNum = function() {
219var num = this.trim();
220return (this.trim().replace(/[^0-9]/g,""));
221}
222
223//-----------------------------------------------------------------------------
224// 숫자만 뺀 나머지 전부
225//
226// @return : 숫자 이외
227//-----------------------------------------------------------------------------
228String.prototype.noNum = function() {
229var num = this.trim();
230return (this.trim().replace(/[0-9]/g,""));
231}
232
233//-----------------------------------------------------------------------------
234// 숫자에 3자리마다 , 를 찍어서 반환
235//
236// @return : 통화량
237
238//-----------------------------------------------------------------------------
239String.prototype.toMoney = function() {
240var num = this.toNum();
241var pattern = /(-?[0-9]+)([0-9]{3})/;
242while(pattern.test(num)) {
243num = num.replace(pattern,"$1,$2");
244}
245return num;
246}
247
248//-----------------------------------------------------------------------------
249// String length 반환
250//
251// @return : int
252//-----------------------------------------------------------------------------
253String.prototype.getLength = function() {
254return this.length;
255}
256
257//-----------------------------------------------------------------------------
258// String length 반환 한글 2글자 영어 1글자
259
260//
261// @return : int
262//-----------------------------------------------------------------------------
263String.prototype.getByteLength = function() {
264var tmplen = 0;
265for (var i = 0; i < this.length; i++) {
266if (this.charCodeAt(i) > 127)
267tmplen += 2;
268else
269tmplen++;
270}
271return tmplen;
272}
273//-----------------------------------------------------------------------------
274// 원단위 콤마
275
276//
277// @return : string
278//-----------------------------------------------------------------------------
279  String.prototype.toCommify=Number.prototype.toCommify=function(){
280    var n = String(this).replace(/\,/g, "");
281    return n.match(RegExp("^[0-9]{"+(n.length%3||3)+"}|[0-9]{3}","g"));
282  }
283
284//-----------------------------------------------------------------------------
285// 전화번호 문자열 체크 (숫자, +, -)
286//
287// @return : true(맞는 형식) | false(잘못된 형식)
288//-----------------------------------------------------------------------------
289  String.prototype.phoneChar = function () {
290      return (this.trim().match(/^[0-9+-]+$/)) ? true : false;
291  }
292//-----------------------------------------------------------------------------
293// 영문 체크 (공백포함)
294//
295// @return : true(맞는 형식) | false(잘못된 형식)
296//-----------------------------------------------------------------------------
297  String.prototype.eng2 = function () {
298      return (this.trim().match(/^[a-zA-Z\s]+$/)) ? true : false;
299  }
300//-----------------------------------------------------------------------------
301// 영문,숫자,공백,허용된 특수문자 (-,.") 체크 
302//
303// @return : true(맞는 형식) | false(잘못된 형식)
304//-----------------------------------------------------------------------------
305  String.prototype.engnum2 = function () {
306      return (this.trim().match(/^[0-9a-zA-Z-,.\"\s]+$/)) ? true : false;
307  }
308//-----------------------------------------------------------------------------
309// 해외 우편번호 문자열 체크 (영문,숫자, -)
310//
311// @return : true(맞는 형식) | false(잘못된 형식)
312//-----------------------------------------------------------------------------
313  String.prototype.zip = function () {
314      return (this.trim().match(/^[0-9a-zA-Z-]+$/)) ? true : false;
315  }
316
317//-----------------------------------------------------------------------------
318// 값이 있는지 체크
319//
320// 
321//-----------------------------------------------------------------------------
322  function isNotEmpty(val) {
323      if (val !== null && val !== '' && typeof val !== 'undefined') {
324          return true;
325      }
326      return false;
327  }
328
329  function isEmpty(val) {
330      return !isNotEmpty(val);
331  }

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.