사용
formSet = new Ext.FormPanel({
id : 'searchForm',
frame: true,
waitMsgTarget: true,
defaultType: 'textfield',
items: [
{
//ID
...
}, {
//이름
name: 'cust_nm',
renderTo : 'div_cust_nm',
width : 150,
maxLength : 50,
vtype: 'isKor',
cls : 'input_color1',
allowBlank: false //필수값
}, {
//전화
name: 'cpy_telno',
renderTo : 'div_cpy_telno',
width : 150,
vtype: 'phone',
cls : 'input_color1',
allowBlank: false,
plugins: new Ext.ux.plugin.FormatPhoneNumber()
}, {
//휴대전화
name: 'cpy_hp',
renderTo : 'div_cpy_hp',
width : 150,
vtype: 'phone',
cls : 'input_color1',
allowBlank: false,
plugins: new Ext.ux.plugin.FormatPhoneNumber()
}, {
name: 'email',
renderTo : 'div_email',
width : 150,
vtype: 'email',
cls : 'input_color1',
allowBlank: false
}, {
...
js 파일
======
/*!
* Ext VTypes
* Version 0.01
*
* Copyright : Yoon Hyuk-Shin
*
*/
// 전화번호 관련 Format
Ext.apply(Ext.form.VTypes, {
'phoneText': '전화번호 형식이 잘못되었습니다.<br /> ex: 050XXXXXXX | 050-XXX-XXXX | 050.XXX.XXXX',
'phoneMask': /[\-\+0-9\(\)\s\.Ext]/,
'phoneRe': /^(01[016789]{1}|02|0[3-9]{1}[0-9]{1})-?[0-9]{3,4}-?[0-9]{4}$/,
//'phoneRe': /^(\({1}[0-9]{3}\){1}\s{1})([0-9]{3}[-]{1}[0-9]{4})$|^(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}$|^Ext. [0-9]+$/,
'phone': function (v) {
return this.phoneRe.test(v);
}
});
//금액 관련 Format
Ext.apply(Ext.form.VTypes, {
'moneyText': '금액 형식이 잘못되었습니다.<br /> ex: 1000 | 1000.10',
'moneyMask': /[\+\-\.\,0-9]/,
'moneyRe': /^[\,\.\+\-0-9]{1,20}$/,
'money': function (v) {
return this.moneyRe.test(v);
}
});
//날짜(년월일) 관련 Format
Ext.apply(Ext.form.VTypes, {
'dateText': '날자 형식이 잘못되었습니다.<br />ex: 20120101 | 2012-01-01 | 2012/01/01 | 2012.01.01',
'dateMask': /[\-\/\.0-9\(\)\s\.Ext]/,
'dateRe': /^\d{4}(\-|\/|\.|)(0[1-9]|1[0-2])\1(0[1-9]|[12][0-9]|3[01])$/,
'date': function (v) {
return this.dateRe.test(v);
}
});
//날짜(년월) 관련 Format
Ext.apply(Ext.form.VTypes, {
'monthText': '날자 형식이 잘못되었습니다.<br />ex: 201201 | 2012-01 | 2012/01/01 | 2012.01',
'monthMask': /[\-\/\.0-9\(\)\s\.Ext]/,
'monthRe': /^\d{4}(\-|\/|\.|)(0[1-9]|1[0-2])$/,
'month': function (v) {
return this.monthRe.test(v);
}
});
//주민번호 관련 Format
Ext.apply(Ext.form.VTypes, {
'juminText': '주민번호 형식이 잘못되었습니다.',
'juminMask': /[\-0-9]/,
'jumin': function(){
var fmt = /^\d{6}[1234]\d{6}$/;
return function(v){
var juminno= v.replace(/[^0-9]/g, '');
var sum_1 = 0;
var sum_2 = 0;
var at=0;
if (!fmt.test(juminno)) return false;
sum_1 = (juminno.charAt(0)*2) + (juminno.charAt(1)*3) + (juminno.charAt(2)*4) + (juminno.charAt(3)*5)+
(juminno.charAt(4)*6) + (juminno.charAt(5)*7) + (juminno.charAt(6)*8) + (juminno.charAt(7)*9)+
(juminno.charAt(8)*2) + (juminno.charAt(9)*3) + (juminno.charAt(10)*4) +(juminno.charAt(11)*5);
sum_2=sum_1 % 11;
if (sum_2 == 0) {
at = 10;
} else {
if (sum_2 == 1) at = 11;
else at = sum_2;
}
att = 11 - at;
if (juminno.charAt(12) != att || juminno.substr(2,2) < '01' || juminno.substr(2,2) > '12' ||
juminno.substr(4,2) < '01' || juminno.substr(4,2) > '31' || juminno.charAt(6) > 4)
{
return false;
} else {
return true;
}
}
}()
});
//사업자번호 관련 Format
Ext.apply(Ext.form.VTypes, {
'bisidText': '사업자번호 형식이 잘못되었습니다.',
'bisidMask': /[\-0-9]/,
'bisid': function(){
var fmt = /^\d{10}$/;
return function(v){
var check_id = v.replace(/[^0-9]/g, '');
var check_mod = 0;
if (!fmt.test(check_id)) return false;
check_mod += parseInt(check_id.substring(0,1));
check_mod += parseInt(check_id.substring(1,2)) * 3 % 10;
check_mod += parseInt(check_id.substring(2,3)) * 7 % 10;
check_mod += parseInt(check_id.substring(3,4)) * 1 % 10;
check_mod += parseInt(check_id.substring(4,5)) * 3 % 10;
check_mod += parseInt(check_id.substring(5,6)) * 7 % 10;
check_mod += parseInt(check_id.substring(6,7)) * 1 % 10;
check_mod += parseInt(check_id.substring(7,8)) * 3 % 10;
check_mod += Math.floor(parseInt(check_id.substring(8,9)) * 5 / 10);
check_mod += parseInt(check_id.substring(8,9)) * 5 % 10;
check_mod += parseInt(check_id.substring(9,10));
if (check_mod % 10 != 0) return false;
else return true;
}
}()
});
//한글입력 방지 관련 Format
Ext.apply(Ext.form.VTypes, {
'notKorText': '한글은 입력할 수 없습니다.',
'notKorMask': /[-_.a-zA-Z0-9]/,
'notKorRe': /^[-_.a-zA-Z0-9]{0,254}$/,
'notKor': function (v) {
return this.notKorRe.test(v);
}
});
//한글만 입력 관련 Format
Ext.apply(Ext.form.VTypes, {
'isKorText': '한글만 입력 가능합니다.',
'isKorMask': /[\ㄱ-ㅎ가-힣]/,
'isKorRe': /^[\ㄱ-ㅎ가-힣]{0,254}$/,
'isKor': function (v) {
return this.isKorRe.test(v);
}
});
//달력 관련 Format2
Ext.apply(Ext.form.VTypes, {
'date2Text' : '날자 형식이 잘못되었습니다, ie: 01/01/2012 | 01.01.2012 | 01-01-2012',
'date2': function(){
var objRegExp = /^(19|20)(\-|\/|\.)(0[1-9]|1[0-2])\1(0[1-9]|[12][0-9]|3[01])$/;
//var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
return function(strValue){
//check to see if in correct format
if(!objRegExp.test(strValue))
return false; //doesn't match pattern, bad date
else{
var strSeparator = strValue.substring(2,3)
var arrayDate = strValue.split(strSeparator);
//create a lookup for months not equal to Feb.
var arrayLookup = { '01' : 31,'03' : 31,
'04' : 30,'05' : 31,
'06' : 30,'07' : 31,
'08' : 31,'09' : 30,
'10' : 31,'11' : 30,'12' : 31}
var intDay = parseInt(arrayDate[1],10);
//check if month value and day value agree
if(arrayLookup[arrayDate[0]] != null) {
if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
return true; //found in lookup table, good date
}
//check for February (bugfix 20050322)
//bugfix for parseInt kevin
//bugfix biss year O.Jp Voutat
var intMonth = parseInt(arrayDate[0],10);
if (intMonth == 2) {
var intYear = parseInt(arrayDate[2]);
if (intDay > 0 && intDay < 29) {
return true;
}
else if (intDay == 29) {
if ((intYear % 4 == 0) && (intYear % 100 != 0) ||
(intYear % 400 == 0)) {
// year div by 4 and ((not div by 100) or div by 400) ->ok
return true;
}
}
}
}
return false; //any other values, bad date
}
}()
});
댓글 없음:
댓글 쓰기