/* * FormCheck Plugin for jQuery JavaScript Library * * Copyright (c) EECIT * Dual licensed under the MIT and GPL licenses. * - http://www.opensource.org/licenses/mit-license.php * - http://www.gnu.org/copyleft/gpl.html * * Author: Dong jin Park * Version: 1.0.0 * Date: 11th July 2010 */ // Form Validate ;(function($){ $.validator = function() { this.form = null; this.error = {result:false,type:'alert',msg:null} }; $.extend($.validator, { //=========================================================================== // Prototype //=========================================================================== prototype:{ validCheck:function(f){ this.form = f; var validator = this; var ele = f.elements; for(var i=0;i" + this.error.msg + ""); if(o.focusid != undefined){ $('#' + o.focusid).focus(); }else{ $(ele).focus(); } }else{ alert(this.error.msg); if(o.focusid != undefined){ $('#' + o.focusid).focus(); }else{ $(ele).focus(); } } this.initError(); }, initError:function(){ this.error.result = false; this.error.type = 'alert'; this.error.msg = null; }, valRequired:function(ele, o){ if(!o.required) return; if($(ele).attr('type')=='checkbox' || $(ele).attr('type')=='radio'){ if(!ele.checked){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] Çʼö üũ Ç׸ñÀÔ´Ï´Ù'; } }else{ if($(ele).val()==''){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] Çʼö Ç׸ñÀÔ´Ï´Ù'; } } }, valEqual:function(ele, o){ if($(ele).val() != $(this.form[o.equal]).val()){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] °ªÀÌ ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù'; } }, valMinlength:function(ele, o){ if ($(ele).val().length < o.minlength){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ÃÖ¼Ò ' + o.minlength + 'ÀÚ ÀÌ»ó ÀÔ·ÂÇϼ¼¿ä.'; } }, valMaxlength:function(ele, o){ if ($(ele).val().length > o.maxlength){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ÃÖ´ë ' + o.maxlength + 'ÀÚ ÀÌ»ó ÀÔ·ÂÇϼ¼¿ä.'; } }, valEmail:function(ele, o){ if(!o.email) return; var pattern = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/; if (!pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] À߸øµÈ À̸ÞÀÏ·Î ÃßÁ¤µË´Ï´Ù.'; } }, valHangul:function(ele, o){ if(!o.hangul) return; var pattern = /[^°¡-ÆR]/; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] Çѱ۸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù'; } }, valHangul2:function(ele, o){ if(!o.hangul2) return; var pattern = /[^°¡-ÆR¤¡-¤¾¤¿-¤Ó]/; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] Çѱ۸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù'; } }, valMemberid:function(ele, o){ if(!o.memberid) return; var pattern = /^[^a-z0-9]|[^a-z0-9_]/; if (pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ȸ¿ø¾ÆÀ̵ð Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù\n\n' + '(¾ËÆĺª¼Ò¹®ÀÚ, ¼ýÀÚ, \'_\' ¸¸ °¡´ÉÇÕ´Ï´Ù. ù±ÛÀÚ ¿µ¹®ÀÚ,¼ýÀÚ)'; } }, valNospace:function(ele, o){ if(!o.nospace) return; var pattern = /(\s)/g; if(pattern.test($(ele).val())){ this.error.result = true; this.error.msg = '[' + o.label + '] °ø¹é¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù'; } }, valNumeric:function(ele, o){ if(!o.numeric) return; var pattern = /[^0-9]/; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù'; } }, valAlpha:function(ele, o){ if(!o.alpha) return; var pattern = /[^a-z]/i; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ¿µ¹®ÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù'; } }, valAlphanumeric:function(ele, o){ if(!o.alphanumeric) return; var pattern = /[^a-z0-9]/i; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù'; } }, valAlphanumeric_:function(ele, o){ if(!o.alphanumeric) return; var pattern = /[^a-z0-9_]/i; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ¿µ¹®ÀÚ, ¼ýÀÚ, \'-\' ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù'; } }, valPhonenumber:function(ele, o){ if(!o.phonenumber) return; var pattern = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{4}$/; if(!pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] À߸øµÈ ¹øÈ£ °°½À´Ï´Ù'; } }, valHangulalphanumeric:function(ele, o){ if(!o.hangulalphanumeric) return; var pattern = /[^°¡-ÆRa-z0-9]/i; if(pattern.test($(ele).val())){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ÇѱÛ, ¿µ¹®, ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù'; } }, // Áֹεî·Ï¹øÈ£ °Ë»ç (±×´©º¸µå¿¡ ÀÖ´ø°Å ¾à°£ ¼öÁ¤) valJumin:function(ele, o){ if(!o.jumin) return; var value = $(ele).val().replace(/[^\d]/g, ''); var pattern = /\d{13}/; if (!pattern.test(value)) { this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ÁֹιøÈ£ 13ÀÚ¸®¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä'; }else{ var sum_1 = 0; var sum_2 = 0; var at=0; var juminno = value; 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){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] ¿Ã¹Ù¸¥ Áֹεî·Ï¹øÈ£°¡ ¾Æ´Õ´Ï´Ù'; } } }, //±Ü¾î ¿Ô´Âµ¥ ´©±¸´Ô²«Áö ±â¾ïÀÌ ¾È³² ¤Ì¤Ì valTaxno:function(ele, o){ if(!o.taxno) return; var value = $(ele).val().replace(/[^\d]/g, ''); var sum = 0; var getlist = new Array(10); var chkvalue = new Array('1','3','7','1','3','7','1','3','5'); for(var i=0; i<10; i++) { getlist[i] = value.substring(i, i+1); } for(var i=0; i<9; i++) { sum += getlist[i]*chkvalue[i]; } sum = sum + parseInt((getlist[8]*5)/10); sidliy = sum % 10; sidchk = 0; if(sidliy != 0) { sidchk = 10 - sidliy; } else { sidchk = 0; } if(sidchk != getlist[9]){ this.error.result = true; this.error.type = 'alert'; this.error.msg = '[' + o.label + '] À߸øµÈ »ç¾÷ÀÚµî·Ï¹øÈ£ÀÔ´Ï´Ù'; } }, valGroupcheck:function(ele, o){ if(!o.groupcheck) return; var flag = false; ele = document.getElementsByName(ele.name); for(i=0;i?~`.- _", nchars: "", allow: "" }, p); return this.each ( function() { if (p.nocaps) p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (p.allcaps) p.nchars += "abcdefghijklmnopqrstuvwxyz"; s = p.allow.split(''); for ( i=0;i>> jQuery.quoteString("apple") "apple" >>> jQuery.quoteString('"Where are we going?", she asked.') "\"Where are we going?\", she asked." **/ $.quoteString = function(string) { if (string.match(_escapeable)) { return '"' + string.replace(_escapeable, function (a) { var c = _meta[a]; if (typeof c === 'string') return c; c = a.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }) + '"'; } return '"' + string + '"'; }; var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g; var _meta = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }; })(jQuery); (function($) { $.setObjValue = function(obj,prop,val) { for (var k in obj) { if(k==prop) obj[prop] = val; } return obj; }; })(jQuery);