|
|
|
|
/*
|
|
|
|
|
ͨ<EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Validform version 5.2 beta
|
|
|
|
|
By sean during April 7, 2010 - July 31, 2012
|
|
|
|
|
For more information, please visit http://validform.rjboy.cn
|
|
|
|
|
Validform is available under the terms of the MIT license.
|
|
|
|
|
|
|
|
|
|
Demo:
|
|
|
|
|
$(".demoform").Validform({//$(".demoform")ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>֤,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>form<72><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
btnSubmit:"#btn_sub", //#btn_sub<75>Ǹñ<C7B8><C3B1><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><F3B6A8B5><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>İ<EFBFBD>ť;<3B><><EFBFBD><EFBFBD>form<72>ں<EFBFBD><DABA><EFBFBD>submit<69><74>ť<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD><CAA1>;
|
|
|
|
|
btnReset:".btn_reset",//<2F><>ѡ<EFBFBD><D1A1> .btn_reset<65>Ǹñ<C7B8><C3B1><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><F3B6A8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>İ<EFBFBD>ť;
|
|
|
|
|
tiptype:1, //<2F><>ѡ<EFBFBD><D1A1> 1=>pop box,2=>side tip<69><70>Ĭ<EFBFBD><C4AC>Ϊ1<CEAA><31>Ҳ<EFBFBD><D2B2><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>һ<EFBFBD><D2BB>function<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>κ<EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD>demoҳ<6F><D2B3>;
|
|
|
|
|
ignoreHidden:false,//<2F><>ѡ<EFBFBD><D1A1> true | false Ĭ<><C4AC>Ϊfalse<73><65><EFBFBD><EFBFBD>Ϊtrueʱ<65><CAB1>:hidden<65>ı<EFBFBD><C4B1><EFBFBD>Ԫ<EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤;
|
|
|
|
|
dragonfly:false,//<2F><>ѡ<EFBFBD><D1A1> true | false Ĭ<><C4AC>false<73><65><EFBFBD><EFBFBD>Ϊtrueʱ<65><CAB1>ֵΪ<D6B5><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
|
|
|
|
tipSweep:true,//<2F><>ѡ<EFBFBD><D1A1> true | false Ĭ<><C4AC>Ϊfalse<73><65><EFBFBD><EFBFBD>trueʱ<65><CAB1>ʾ<EFBFBD><CABE>Ϣ<EFBFBD><CFA2>ֻ<EFBFBD><D6BB><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>ύʱ<E1BDBB><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>blurʱ<72><CAB1><EFBFBD>ᱻ<EFBFBD><E1B1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ;
|
|
|
|
|
showAllError:false,//<2F><>ѡ<EFBFBD><D1A1> true | false<73><65>true<75><65><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>false<73><65>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>ͨ<EFBFBD><CDA8><EFBFBD>ľ<EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>ֻ<EFBFBD><D6BB>ʾ<EFBFBD><CABE>Ԫ<EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|
|
|
|
postonce:true, //<2F><>ѡ<EFBFBD><D1A1> <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>Ϲر<CFB9>;
|
|
|
|
|
ajaxPost:true, //ʹ<><CAB9>ajax<61><78>ʽ<EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ĭ<EFBFBD><C4AC>false<73><65><EFBFBD>ύ<EFBFBD><E1BDBB>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>actionָ<6E><D6B8><EFBFBD><EFBFBD>ַ;
|
|
|
|
|
datatype:{//<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>datatype<70><65><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>Ǻ<EFBFBD><C7BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻᴫ<DABB><E1B4AB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
"*6-20": /^[^\s]{6,20}$/,
|
|
|
|
|
"z2-4" : /^[\u4E00-\u9FA5\uf900-\ufa2d]{2,4}$/,
|
|
|
|
|
"username":function(gets,obj,curform,regxp){
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>gets<74>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>Ԫ<EFBFBD><D4AA>ֵ<EFBFBD><D6B5>objΪ<6A><CEAA>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>curformΪ<6D><CEAA>ǰ<EFBFBD><C7B0>֤<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>regxpΪ<70><CEAA><EFBFBD>õ<EFBFBD>һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
var reg1=/^[\w\.]{4,16}$/,
|
|
|
|
|
reg2=/^[\u4E00-\u9FA5\uf900-\ufa2d]{2,8}$/;
|
|
|
|
|
|
|
|
|
|
if(reg1.test(gets)){return true;}
|
|
|
|
|
if(reg2.test(gets)){return true;}
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
//ע<><D7A2>return<72><6E><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>true <20><> false <20><> <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>true<75><65>ʾ<EFBFBD><CABE>֤ͨ<D6A4><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>֤ʧ<D6A4>ܣ<EFBFBD><DCA3>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false<73><65><EFBFBD><EFBFBD>errmsg<73><67>Ĭ<EFBFBD>ϵĴ<CFB5><C4B4><EFBFBD><EFBFBD><EFBFBD>ʾ;
|
|
|
|
|
},
|
|
|
|
|
"phone":function(){
|
|
|
|
|
// 5.0 <20>汾֮<E6B1BE><D6AE><EFBFBD><EFBFBD>Ҫʵ<D2AA>ֶ<EFBFBD>ѡһ<D1A1><D2BB><EFBFBD><EFBFBD>֤Ч<D6A4><D0A7><EFBFBD><EFBFBD>datatype <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><>Ҫ<EFBFBD><D2AA> "option_" <20><>ͷ;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
usePlugin:{
|
|
|
|
|
swfupload:{},
|
|
|
|
|
datepicker:{},
|
|
|
|
|
passwordstrength:{},
|
|
|
|
|
jqtransform:{
|
|
|
|
|
selector:"select,input"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeCheck:function(curform){
|
|
|
|
|
//<2F>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>ύִ<E1BDBB><D6B4><EFBFBD><EFBFBD>֤֮ǰִ<C7B0>еĺ<D0B5><C4BA><EFBFBD><EFBFBD><EFBFBD>curform<72><6D><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷreturn false<73>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>;
|
|
|
|
|
},
|
|
|
|
|
beforeSubmit:function(curform){
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>֤<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><F3A3ACB1><EFBFBD><EFBFBD>ύǰִ<C7B0>еĺ<D0B5><C4BA><EFBFBD><EFBFBD><EFBFBD>curform<72><6D><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷreturn false<73>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ;
|
|
|
|
|
},
|
|
|
|
|
callback:function(data){
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>data<74><61>json<6F><6E>ʽ<EFBFBD><CABD>{"info":"demo info","status":"y"}
|
|
|
|
|
//info: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ;
|
|
|
|
|
//status: <20><><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD>ݵ<EFBFBD>״̬,<2C>Ƿ<EFBFBD><C7B7>ύ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"y"<22><>ʾ<EFBFBD>ύ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>"n"<22><>ʾ<EFBFBD>ύʧ<E1BDBB>ܣ<EFBFBD><DCA3><EFBFBD>ajax_post.php<68>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>callback<63><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ִֵ<D6B5><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
//<2F><>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ajax_post.php<68>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ִ<EFBFBD>лص<D0BB><D8B5><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
//ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ajax<61><78>ʽ<EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>callback<63><6B><EFBFBD><EFBFBD>ʱdata<74><61><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<F3A3ACBB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD>֤ȫ<D6A4><C8AB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ִ<EFBFBD>У<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>callback<63><6B><EFBFBD><EFBFBD>ȷreturn false<73><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>return true<75><65>û<EFBFBD><C3BB>return<72><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Validform<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>
|
|
|
|
|
tipmsg<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Validform<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD><EFBFBD>ҳ<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ò<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>
|
|
|
|
|
dataType<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
eq(n)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡValidform<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>n<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>;
|
|
|
|
|
ajaxPost(flag,sync)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ajax<EFBFBD><EFBFBD>ʽ<EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>flagΪtrueʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ֤<EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>syncΪtrueʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ajax<EFBFBD>ύ<EFBFBD><EFBFBD>
|
|
|
|
|
abort()<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹajax<EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>
|
|
|
|
|
submitForm(flag)<EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õķ<EFBFBD>ʽ<EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>flagΪtrueʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ֤<EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>
|
|
|
|
|
resetForm()<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
resetStatus()<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>postonce<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ"posted"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>
|
|
|
|
|
getStatus()<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ״̬<EFBFBD><EFBFBD>normal<EFBFBD><EFBFBD>δ<EFBFBD>ύ<EFBFBD><EFBFBD>posting<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>posted<EFBFBD><EFBFBD><EFBFBD>ѳɹ<EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
setStatus(status)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>normal<EFBFBD><EFBFBD>posting<EFBFBD><EFBFBD>posted<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬Ϊposting<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD>
|
|
|
|
|
ignore(selector)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>
|
|
|
|
|
unignore(selector)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ignore<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD>ȡ<EFBFBD><EFBFBD>֤Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
addRule(rule)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>Validform<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ذ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function($, win, undef) {
|
|
|
|
|
var errorobj = null, //ָʾ<D6B8><CABE>ǰ<EFBFBD><C7B0>֤ʧ<D6A4>ܵı<DCB5><C4B1><EFBFBD>Ԫ<EFBFBD><D4AA>;
|
|
|
|
|
msgobj = null, //pop box object
|
|
|
|
|
msghidden = true; //msgbox hidden?
|
|
|
|
|
|
|
|
|
|
var tipmsg = {//Ĭ<><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>;
|
|
|
|
|
tit: "<22><>ʾ<EFBFBD><CABE>Ϣ",
|
|
|
|
|
w: "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>Ϣ<EFBFBD><CFA2>",
|
|
|
|
|
r: "ͨ<><CDA8><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>֤<EFBFBD><D6A4>",
|
|
|
|
|
c: "<22><><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>",
|
|
|
|
|
s: "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>",
|
|
|
|
|
v: "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣû<CFA2>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>",
|
|
|
|
|
p: "<22><><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD>ݡ<EFBFBD>",
|
|
|
|
|
err: "<22><><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB>ַ<EFBFBD><EFBFBD><F2B7B5BB><EFBFBD><EFBFBD>ݸ<EFBFBD>ʽ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ<EFBFBD><C8B7>",
|
|
|
|
|
abort: "Ajax<61><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>"
|
|
|
|
|
}
|
|
|
|
|
$.Tipmsg = tipmsg;
|
|
|
|
|
|
|
|
|
|
var Validform = function(forms, settings, inited) {
|
|
|
|
|
var settings = $.extend({}, Validform.defaults, settings);
|
|
|
|
|
settings.datatype && $.extend(Validform.util.dataType, settings.datatype);
|
|
|
|
|
|
|
|
|
|
var brothers = this;
|
|
|
|
|
brothers.tipmsg = {};
|
|
|
|
|
brothers.settings = settings;
|
|
|
|
|
brothers.forms = forms;
|
|
|
|
|
brothers.objects = [];
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ٰ<EFBFBD><D9B0><EFBFBD><EFBFBD>¼<EFBFBD>;
|
|
|
|
|
if (inited === true) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
forms.each(function(n) {
|
|
|
|
|
|
|
|
|
|
var $this = $(this);
|
|
|
|
|
|
|
|
|
|
//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť˫<C5A5><CBAB><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>;
|
|
|
|
|
this.validform_status = "normal"; //normal | posting | posted;
|
|
|
|
|
|
|
|
|
|
//<2F><>ÿ<EFBFBD><C3BF>Validform<72><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>tipmsg;
|
|
|
|
|
$this.data("tipmsg", brothers.tipmsg);
|
|
|
|
|
|
|
|
|
|
//bind the blur event;
|
|
|
|
|
$this.find("[datatype]").live("blur", function() {
|
|
|
|
|
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var subpost = arguments[1];
|
|
|
|
|
Validform.util.check.call(this, $this, brothers, subpost);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>أ<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ<CAA7><D0A7>;
|
|
|
|
|
Validform.util.hasDefaultText.call($this);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>ֵ<EFBFBD>Ƚ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ<EFBFBD><CABE>ǿ;
|
|
|
|
|
Validform.util.recheckEnhance.call($this);
|
|
|
|
|
|
|
|
|
|
//plugins here to start;
|
|
|
|
|
if (settings.usePlugin) {
|
|
|
|
|
Validform.util.usePlugin.call($this, settings.usePlugin, settings.tiptype, settings.tipSweep, n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//enhance info feedback for checkbox & radio;
|
|
|
|
|
$this.find(":checkbox[datatype],:radio[datatype]").each(function() {
|
|
|
|
|
var _this = $(this);
|
|
|
|
|
var name = _this.attr("name");
|
|
|
|
|
$this.find("[name='" + name + "']").filter(":checkbox,:radio").bind("click", function() {
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȡֵ<C8A1>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
_this.trigger("blur");
|
|
|
|
|
}, 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
settings.btnSubmit && $this.find(settings.btnSubmit).bind("click", function() {
|
|
|
|
|
var subflag = Validform.util.submitForm.call($this, settings);
|
|
|
|
|
subflag === undef && (subflag = true);
|
|
|
|
|
if (subflag === true) {
|
|
|
|
|
//$this[0].submit();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$this.submit(function() {
|
|
|
|
|
var subflag = Validform.util.submitForm.call($this, settings);
|
|
|
|
|
subflag === undef && (subflag = true);
|
|
|
|
|
return subflag;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$this.find("[type='reset']").add($this.find(settings.btnReset)).bind("click", function() {
|
|
|
|
|
Validform.util.resetForm.call($this);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//Ԥ<><D4A4><EFBFBD><EFBFBD>pop box;
|
|
|
|
|
if (settings.tiptype == 1 || (settings.tiptype == 2 && settings.ajaxPost)) {
|
|
|
|
|
creatMsgbox();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Validform.defaults = {
|
|
|
|
|
tiptype: 1,
|
|
|
|
|
tipSweep: false,
|
|
|
|
|
showAllError: false,
|
|
|
|
|
postonce: false,
|
|
|
|
|
ajaxPost: false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Validform.util = {
|
|
|
|
|
dataType: {
|
|
|
|
|
"match": /^(.+?)(\d+)-(\d+)$/,
|
|
|
|
|
"*": /[\w\W]+/,
|
|
|
|
|
"*6-16": /^[\w\W]{6,16}$/,
|
|
|
|
|
"n": /^\d+$/,
|
|
|
|
|
"n6-16": /^\d{6,16}$/,
|
|
|
|
|
"n6-8": /^\d{6,8}$/,
|
|
|
|
|
"s": /^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]+$/,
|
|
|
|
|
"s6-18": /^[\u4E00-\u9FA5\uf900-\ufa2d\w\.\s]{6,18}$/,
|
|
|
|
|
"p": /^[0-9]{6}$/,
|
|
|
|
|
"m": /^1[0-9]{10}$/,
|
|
|
|
|
"e": /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
|
|
|
|
|
"url": /^(\w+:\/\/)?\w+(\.\w+)+.*$/
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toString: Object.prototype.toString,
|
|
|
|
|
|
|
|
|
|
getValue: function(obj) {
|
|
|
|
|
var inputval,
|
|
|
|
|
curform = this;
|
|
|
|
|
|
|
|
|
|
if (obj.is(":radio")) {
|
|
|
|
|
inputval = curform.find(":radio[name='" + obj.attr("name") + "']:checked").val();
|
|
|
|
|
inputval = inputval === undef ? "" : inputval;
|
|
|
|
|
} else if (obj.is(":checkbox")) {
|
|
|
|
|
inputval = curform.find(":checkbox[name='" + obj.attr("name") + "']:checked").val();
|
|
|
|
|
inputval = inputval === undef ? "" : inputval;
|
|
|
|
|
} else {
|
|
|
|
|
inputval = obj.val();
|
|
|
|
|
}
|
|
|
|
|
return $.trim(inputval);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isEmpty: function(val) {
|
|
|
|
|
return val === "" || val === $.trim(this.attr("tip"));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
recheckEnhance: function() {
|
|
|
|
|
var curform = this;
|
|
|
|
|
curform.find("input[recheck]").each(function() {
|
|
|
|
|
var _this = $(this);
|
|
|
|
|
var recheckinput = curform.find("input[name='" + $(this).attr("recheck") + "']");
|
|
|
|
|
recheckinput.bind("keyup", function() {
|
|
|
|
|
if (recheckinput.val() == _this.val() && recheckinput.val() != "") {
|
|
|
|
|
if (recheckinput.attr("tip")) {
|
|
|
|
|
if (recheckinput.attr("tip") == recheckinput.val()) { return false; }
|
|
|
|
|
}
|
|
|
|
|
_this.trigger("blur");
|
|
|
|
|
}
|
|
|
|
|
}).bind("blur", function() {
|
|
|
|
|
if (recheckinput.val() != _this.val() && _this.val() != "") {
|
|
|
|
|
if (_this.attr("tip")) {
|
|
|
|
|
if (_this.attr("tip") == _this.val()) { return false; }
|
|
|
|
|
}
|
|
|
|
|
_this.trigger("blur");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
hasDefaultText: function() {
|
|
|
|
|
this.find("[tip]").each(function() {//tip<69>DZ<EFBFBD><C7B1><EFBFBD>Ԫ<EFBFBD>ص<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ,<2C><><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>;
|
|
|
|
|
var defaultvalue = $(this).attr("tip");
|
|
|
|
|
var altercss = $(this).attr("altercss");
|
|
|
|
|
$(this).focus(function() {
|
|
|
|
|
if ($(this).val() == defaultvalue) {
|
|
|
|
|
$(this).val('');
|
|
|
|
|
if (altercss) { $(this).removeClass(altercss); }
|
|
|
|
|
}
|
|
|
|
|
}).blur(function() {
|
|
|
|
|
if ($.trim($(this).val()) === '') {
|
|
|
|
|
$(this).val(defaultvalue);
|
|
|
|
|
if (altercss) { $(this).addClass(altercss); }
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
usePlugin: function(plugin, tiptype, tipSweep, n) {
|
|
|
|
|
/*
|
|
|
|
|
plugin:settings.usePlugin;
|
|
|
|
|
tiptype:settings.tiptype;
|
|
|
|
|
tipSweep:settings.tipSweep;
|
|
|
|
|
n:<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var curform = this;
|
|
|
|
|
//swfupload;
|
|
|
|
|
if (plugin.swfupload) {
|
|
|
|
|
var swfuploadinput = curform.find("input[plugin='swfupload']").val(""),
|
|
|
|
|
custom = {
|
|
|
|
|
custom_settings: {
|
|
|
|
|
form: curform,
|
|
|
|
|
showmsg: function(msg, type) {
|
|
|
|
|
Validform.util.showmsg.call(curform, msg, tiptype, { obj: swfuploadinput, type: type, sweep: tipSweep });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
custom = $.extend(true, {}, plugin.swfupload, custom);
|
|
|
|
|
if (typeof (swfuploadhandler) != "undefined") { swfuploadhandler.init(custom, n); }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//datepicker;
|
|
|
|
|
if (plugin.datepicker) {
|
|
|
|
|
if (plugin.datepicker.format) {
|
|
|
|
|
Date.format = plugin.datepicker.format;
|
|
|
|
|
delete plugin.datepicker.format;
|
|
|
|
|
}
|
|
|
|
|
if (plugin.datepicker.firstDayOfWeek) {
|
|
|
|
|
Date.firstDayOfWeek = plugin.datepicker.firstDayOfWeek;
|
|
|
|
|
delete plugin.datepicker.firstDayOfWeek;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var datepickerinput = curform.find("input[plugin='datepicker']");
|
|
|
|
|
plugin.datepicker.callback && datepickerinput.bind("dateSelected", function() {
|
|
|
|
|
var d = new Date($.event._dpCache[this._dpId].getSelected()[0]).asString(Date.format);
|
|
|
|
|
plugin.datepicker.callback(d, this);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
datepickerinput.datePicker(plugin.datepicker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//passwordstrength;
|
|
|
|
|
if (plugin.passwordstrength) {
|
|
|
|
|
plugin.passwordstrength.showmsg = function(obj, msg, type) {
|
|
|
|
|
Validform.util.showmsg.call(curform, msg, tiptype, { obj: obj, type: type, sweep: tipSweep }, "hide");
|
|
|
|
|
};
|
|
|
|
|
curform.find("input[plugin*='passwordStrength']").passwordStrength(plugin.passwordstrength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//jqtransform;
|
|
|
|
|
if (plugin.jqtransform) {
|
|
|
|
|
var jqTransformHideSelect = function(oTarget) {
|
|
|
|
|
var ulVisible = $('.jqTransformSelectWrapper ul:visible');
|
|
|
|
|
ulVisible.each(function() {
|
|
|
|
|
var oSelect = $(this).parents(".jqTransformSelectWrapper:first").find("select").get(0);
|
|
|
|
|
//do not hide if click on the label object associated to the select
|
|
|
|
|
if (!(oTarget && oSelect.oLabel && oSelect.oLabel.get(0) == oTarget.get(0))) { $(this).hide(); }
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Check for an external click */
|
|
|
|
|
var jqTransformCheckExternalClick = function(event) {
|
|
|
|
|
if ($(event.target).parents('.jqTransformSelectWrapper').length === 0) { jqTransformHideSelect($(event.target)); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var jqTransformAddDocumentListener = function() {
|
|
|
|
|
$(document).mousedown(jqTransformCheckExternalClick);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (plugin.jqtransform.selector) {
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter('input:submit, input:reset, input[type="button"]').jqTransInputButton();
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter('input:text, input:password').jqTransInputText();
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter('input:checkbox').jqTransCheckBox();
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter('input:radio').jqTransRadio();
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter('textarea').jqTransTextarea();
|
|
|
|
|
if (curform.find(plugin.jqtransform.selector).filter("select").length > 0) {
|
|
|
|
|
curform.find(plugin.jqtransform.selector).filter("select").jqTransSelect();
|
|
|
|
|
jqTransformAddDocumentListener();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
curform.jqTransform();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curform.find(".jqTransformSelectWrapper").find("li a").click(function() {
|
|
|
|
|
curform.find("select").trigger("blur");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_regcheck: function(datatype, gets, obj, curform) {
|
|
|
|
|
var curform = curform,
|
|
|
|
|
info = null,
|
|
|
|
|
passed = false,
|
|
|
|
|
type = 3; //default set to wrong type, 2,3,4;
|
|
|
|
|
|
|
|
|
|
if (Validform.util.toString.call(Validform.util.dataType[datatype]) == "[object Function]") {
|
|
|
|
|
passed = Validform.util.dataType[datatype](gets, obj, curform, Validform.util.dataType);
|
|
|
|
|
if (passed === true || passed === undef) {
|
|
|
|
|
passed = true;
|
|
|
|
|
type = 2;
|
|
|
|
|
info = curform.data("tipmsg").r || tipmsg.r;
|
|
|
|
|
|
|
|
|
|
if (obj.attr("recheck")) {
|
|
|
|
|
var theother = curform.find("input[name='" + obj.attr("recheck") + "']:first");
|
|
|
|
|
if (gets != theother.val()) {
|
|
|
|
|
passed = false;
|
|
|
|
|
type = 3;
|
|
|
|
|
info = obj.attr("errormsg") || curform.data("tipmsg").w || tipmsg.w;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
info = passed || obj.attr("errormsg") || curform.data("tipmsg").w || tipmsg.w;
|
|
|
|
|
passed = false;
|
|
|
|
|
if (gets === "") {//<2F><>֤<EFBFBD><D6A4>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ʱ;
|
|
|
|
|
return {
|
|
|
|
|
passed: false,
|
|
|
|
|
type: 3,
|
|
|
|
|
info: obj.attr("nullmsg") || curform.data("tipmsg").s || tipmsg.s
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
passed: passed,
|
|
|
|
|
type: type,
|
|
|
|
|
info: info
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(datatype in Validform.util.dataType)) {
|
|
|
|
|
var mac = datatype.match(Validform.util.dataType["match"]),
|
|
|
|
|
temp;
|
|
|
|
|
|
|
|
|
|
if (!mac) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var name in Validform.util.dataType) {
|
|
|
|
|
temp = name.match(Validform.util.dataType["match"]);
|
|
|
|
|
if (!temp) { continue; }
|
|
|
|
|
if (mac[1] === temp[1]) {
|
|
|
|
|
var str = Validform.util.dataType[name].toString(),
|
|
|
|
|
param = str.match(/\/[mgi]*/g)[1].replace("\/", ""),
|
|
|
|
|
regxp = new RegExp("\\{" + temp[2] + "," + temp[3] + "\\}", "g");
|
|
|
|
|
str = str.replace(/\/[mgi]*/g, "\/").replace(regxp, "{" + mac[2] + "," + mac[3] + "}").replace(/^\//, "").replace(/\/$/, "");
|
|
|
|
|
Validform.util.dataType[datatype] = new RegExp(str, param);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Validform.util.toString.call(Validform.util.dataType[datatype]) == "[object RegExp]") {
|
|
|
|
|
passed = Validform.util.dataType[datatype].test(gets);
|
|
|
|
|
|
|
|
|
|
if (passed) {
|
|
|
|
|
type = 2;
|
|
|
|
|
info = curform.data("tipmsg").r || tipmsg.r;
|
|
|
|
|
|
|
|
|
|
if (obj.attr("recheck")) {
|
|
|
|
|
var theother = curform.find("input[name='" + obj.attr("recheck") + "']:first");
|
|
|
|
|
if (gets != theother.val()) {
|
|
|
|
|
passed = false;
|
|
|
|
|
type = 3;
|
|
|
|
|
info = obj.attr("errormsg") || curform.data("tipmsg").w || tipmsg.w;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
info = obj.attr("errormsg") || curform.data("tipmsg").w || tipmsg.w;
|
|
|
|
|
|
|
|
|
|
if (gets === "") {
|
|
|
|
|
return {
|
|
|
|
|
passed: false,
|
|
|
|
|
type: 3,
|
|
|
|
|
info: obj.attr("nullmsg") || curform.data("tipmsg").s || tipmsg.s
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
passed: passed,
|
|
|
|
|
type: type,
|
|
|
|
|
info: info
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
passed: false,
|
|
|
|
|
type: 3,
|
|
|
|
|
info: curform.data("tipmsg").w || tipmsg.w
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
regcheck: function(datatype, gets, obj) {
|
|
|
|
|
/*
|
|
|
|
|
datatype:datatype;
|
|
|
|
|
gets:inputvalue;
|
|
|
|
|
obj:input object;
|
|
|
|
|
*/
|
|
|
|
|
var curform = this,
|
|
|
|
|
info = null,
|
|
|
|
|
passed = false,
|
|
|
|
|
type = 3; //default set to wrong type, 2,3,4;
|
|
|
|
|
|
|
|
|
|
//ignore;
|
|
|
|
|
if (obj.attr("ignore") === "ignore" && Validform.util.isEmpty.call(obj, gets)) {
|
|
|
|
|
if (obj.data("cked")) {
|
|
|
|
|
info = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
passed: true,
|
|
|
|
|
type: 4,
|
|
|
|
|
info: info
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj.data("cked", "cked"); //do nothing if is the first time validation triggered;
|
|
|
|
|
|
|
|
|
|
//default value;
|
|
|
|
|
if ($.trim(obj.attr("tip")) && gets === $.trim(obj.attr("tip"))) {
|
|
|
|
|
return {
|
|
|
|
|
passed: false,
|
|
|
|
|
type: 3,
|
|
|
|
|
info: obj.attr("nullmsg") || curform.data("tipmsg").s || tipmsg.s
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var eithor = datatype.indexOf("|") == -1 ? false : true;
|
|
|
|
|
var datatype = datatype.split(/,|\|/);
|
|
|
|
|
var res;
|
|
|
|
|
|
|
|
|
|
for (var dtype = 0; dtype < datatype.length;dtype++) {
|
|
|
|
|
res = Validform.util._regcheck($.trim(datatype[dtype]), gets, obj, curform);
|
|
|
|
|
if (!res.passed && !eithor || res.passed && eithor) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showmsg: function(msg, type, o, show) {
|
|
|
|
|
/*
|
|
|
|
|
msg:<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
type:<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʽ;
|
|
|
|
|
o:{obj:<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, type:1=><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD><EFBFBD> | 2=>ͨ<EFBFBD><EFBFBD>},
|
|
|
|
|
show:<EFBFBD><EFBFBD>blur<EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD>嵯<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫÿ<EFBFBD><EFBFBD>blurʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>msgΪnull<6C><6C><EFBFBD><EFBFBD>ô<EFBFBD><C3B4>û<EFBFBD><C3BB>Ҫִ<D2AA>к<EFBFBD><D0BA><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>ignore<72>п<EFBFBD><D0BF>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
if (msg === null) { return false; }
|
|
|
|
|
//if(msg===null || o.sweep && show=="hide"){return false;}
|
|
|
|
|
|
|
|
|
|
$.extend(o, { curform: this });
|
|
|
|
|
|
|
|
|
|
if (typeof type == "function") {
|
|
|
|
|
if (!(o.sweep && show == "hide")) {
|
|
|
|
|
type(msg, o, Validform.util.cssctl);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == 1 || show == "alwaysshow") {
|
|
|
|
|
msgobj.find(".Validform_info").html(msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == 1 && show != "hide" || show == "alwaysshow") {
|
|
|
|
|
msghidden = false;
|
|
|
|
|
msgobj.find(".iframe").css("height", msgobj.outerHeight());
|
|
|
|
|
msgobj.show();
|
|
|
|
|
setCenter(msgobj, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == 2 && o.obj) {
|
|
|
|
|
o.obj.parent().next().find(".Validform_checktip").html(msg);
|
|
|
|
|
Validform.util.cssctl(o.obj.parent().next().find(".Validform_checktip"), o.type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showConfirm: function(_argument) {
|
|
|
|
|
(_argument.skinCss) ? msgobj.addClass(_argument.skinCss) : "";
|
|
|
|
|
if (_argument.caption) {
|
|
|
|
|
var tmpClose = msgobj.find(".Validform_title").find(".Validform_close").clone(true);
|
|
|
|
|
msgobj.find(".Validform_title").html(_argument.caption).andSelf().append(tmpClose);
|
|
|
|
|
}
|
|
|
|
|
var cfmBody = msgobj.find(".Validform_info");
|
|
|
|
|
//cfmBody.text(_argument.msg);
|
|
|
|
|
cfmBody.html(_argument.msg);
|
|
|
|
|
|
|
|
|
|
if (_argument.btn) {
|
|
|
|
|
var btnWrapCss = (_argument.btnWrapCss) ? "." + _argument.btnWrapCss : ".btns";
|
|
|
|
|
if (cfmBody.find(btnWrapCss).length != 0) {
|
|
|
|
|
cfmBody.find(btnWrapCss).empty();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cfmBody.append("<div class=\"mt20 tc " + btnWrapCss.replace(".", "") + "\"></div>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hasBtnCss = (_argument.btnCss && _argument.btnCss.length > 0) ? true : false;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < _argument.btn.length; i++) {
|
|
|
|
|
var btnCss = (hasBtnCss) ? _argument.btnCss[i] : "btn" + i;
|
|
|
|
|
var btn = $("<a class=\"btn btn_gray25 mr20 " + btnCss + "\" rel=\"" + i + "\" href=\"javascript:void(0)\"><span>" + _argument.btn[i] + "</span></a>").click(function() {
|
|
|
|
|
_argument.callback[this.rel].call(this, msgobj, this);
|
|
|
|
|
});
|
|
|
|
|
cfmBody.find(btnWrapCss).append(btn);
|
|
|
|
|
btn = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msgobj.find(".iframe").css("height", msgobj.height());
|
|
|
|
|
msghidden = false;
|
|
|
|
|
var left = ($(window).width() - msgobj.width()) / 2;
|
|
|
|
|
var top = ($(window).height() - msgobj.height()) / 2;
|
|
|
|
|
top = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + (top > 0 ? top : 0);
|
|
|
|
|
msgobj.css({
|
|
|
|
|
"left": left
|
|
|
|
|
}).show().animate({
|
|
|
|
|
top: top
|
|
|
|
|
}, 100, function() {
|
|
|
|
|
if (_argument.showedCallback) {
|
|
|
|
|
_argument.showedCallback.call(this, this);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
cssctl: function(obj, status) {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case 1:
|
|
|
|
|
obj.removeClass("Validform_right Validform_wrong").addClass("Validform_checktip Validform_loading"); //checking;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
obj.removeClass("Validform_wrong Validform_loading").addClass("Validform_checktip Validform_right"); //passed;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
obj.removeClass("Validform_right Validform_wrong Validform_loading").addClass("Validform_checktip"); //for ignore;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
obj.removeClass("Validform_right Validform_loading").addClass("Validform_checktip Validform_wrong"); //wrong;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
check: function(curform, brothers, subpost, bool) {
|
|
|
|
|
/*
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>ⵥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>;
|
|
|
|
|
<EFBFBD><EFBFBD>֤ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false<EFBFBD><EFBFBD>ʵʱ<EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪajax;
|
|
|
|
|
bool<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ⲻ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ;
|
|
|
|
|
*/
|
|
|
|
|
var $this = curform;
|
|
|
|
|
var settings = brothers.settings;
|
|
|
|
|
var subpost = subpost || "";
|
|
|
|
|
var inputval = Validform.util.getValue.call($this, $(this));
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dataIgnore<72><65><EFBFBD>ԵĶ<D4B5><C4B6><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤;
|
|
|
|
|
//dragonfly=trueʱ<65><CAB1>ֵΪ<D6B5>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD>֤;
|
|
|
|
|
|
|
|
|
|
if ($(this).data("dataIgnore") === "dataIgnore" || settings.dragonfly && !$(this).data("cked") && Validform.util.isEmpty.call($(this), inputval)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var flag = true,
|
|
|
|
|
_this;
|
|
|
|
|
errorobj = _this = $(this);
|
|
|
|
|
|
|
|
|
|
flag = Validform.util.regcheck.call($this, $(this).attr("datatype"), inputval, $(this));
|
|
|
|
|
if (!flag.passed) {
|
|
|
|
|
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD>е<EFBFBD>ajax<61><78>֤;
|
|
|
|
|
Validform.util.abort.call(_this[0]);
|
|
|
|
|
|
|
|
|
|
if (!bool) {
|
|
|
|
|
_this.addClass("Validform_error");
|
|
|
|
|
Validform.util.showmsg.call($this, flag.info, settings.tiptype, { obj: $(this), type: flag.type, sweep: settings.tipSweep }, "hide"); //<2F><>tiptype=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>"hide"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><F2B2BBB5><EFBFBD>,tiptype=2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><C2B8>Ӳ<EFBFBD><D3B2><EFBFBD>"hide"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
if ($(this).attr("ajaxurl") && !bool) {
|
|
|
|
|
var inputobj = $(this);
|
|
|
|
|
if (inputobj[0].validform_valid === "posting" && inputval == inputobj[0].validform_ckvalue) { return "ajax"; }
|
|
|
|
|
|
|
|
|
|
inputobj[0].validform_valid = "posting";
|
|
|
|
|
inputobj[0].validform_ckvalue = inputval;
|
|
|
|
|
Validform.util.showmsg.call($this, brothers.tipmsg.c || tipmsg.c, settings.tiptype, { obj: inputobj, type: 1, sweep: settings.tipSweep }, "hide");
|
|
|
|
|
|
|
|
|
|
Validform.util.abort.call(_this[0]);
|
|
|
|
|
_this[0].validform_ajax = $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
url: inputobj.attr("ajaxurl"),
|
|
|
|
|
data: "param=" + inputval + "&name=" + $(this).attr("name"),
|
|
|
|
|
dataType: "text",
|
|
|
|
|
success: function(s) {
|
|
|
|
|
if ($.trim(s) == "y") {
|
|
|
|
|
inputobj[0].validform_valid = "true";
|
|
|
|
|
Validform.util.showmsg.call($this, brothers.tipmsg.r || tipmsg.r, settings.tiptype, { obj: inputobj, type: 2, sweep: settings.tipSweep }, "hide");
|
|
|
|
|
_this.removeClass("Validform_error");
|
|
|
|
|
errorobj = null;
|
|
|
|
|
if (subpost === "postform") {
|
|
|
|
|
$this.trigger("submit");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
inputobj[0].validform_valid = s;
|
|
|
|
|
_this.addClass("Validform_error");
|
|
|
|
|
Validform.util.showmsg.call($this, s, settings.tiptype, { obj: inputobj, type: 3, sweep: settings.tipSweep });
|
|
|
|
|
}
|
|
|
|
|
_this[0].validform_ajax = null;
|
|
|
|
|
},
|
|
|
|
|
error: function(data) {
|
|
|
|
|
if (data.statusText !== "abort") {
|
|
|
|
|
_this.addClass("Validform_error");
|
|
|
|
|
Validform.util.showmsg.call($this, brothers.tipmsg.err || tipmsg.err, settings.tiptype, { obj: inputobj, type: 3, sweep: settings.tipSweep });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inputobj[0].validform_valid = brothers.tipmsg.err || tipmsg.err;
|
|
|
|
|
_this[0].validform_ajax = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return "ajax";
|
|
|
|
|
} else {
|
|
|
|
|
if (!bool) {
|
|
|
|
|
Validform.util.showmsg.call($this, flag.info, settings.tiptype, { obj: $(this), type: flag.type, sweep: settings.tipSweep }, "hide");
|
|
|
|
|
_this.removeClass("Validform_error");
|
|
|
|
|
}
|
|
|
|
|
errorobj = null;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submitForm: function(settings, flg, ajaxPost, sync) {
|
|
|
|
|
/*
|
|
|
|
|
flg===trueʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ֤<EFBFBD><EFBFBD><EFBFBD>ύ;
|
|
|
|
|
ajaxPost==="ajaxPost"ָʾ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ajax<EFBFBD><EFBFBD>ʽ<EFBFBD>ύ;
|
|
|
|
|
*/
|
|
|
|
|
var curform = this;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύʱ<E1BDBB><CAB1><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ;
|
|
|
|
|
if (curform[0].validform_status === "posting") { return false; }
|
|
|
|
|
|
|
|
|
|
//Ҫ<><D2AA>ֻ<EFBFBD><D6BB><EFBFBD>ύһ<E1BDBB><D2BB>ʱ;
|
|
|
|
|
if (settings.postonce && curform[0].validform_status === "posted") { return false; }
|
|
|
|
|
|
|
|
|
|
var sync = sync === true ? false : true;
|
|
|
|
|
var beforeCheck = settings.beforeCheck && settings.beforeCheck(curform);
|
|
|
|
|
if (beforeCheck === false) { return false; }
|
|
|
|
|
|
|
|
|
|
var flag = true,
|
|
|
|
|
inflag;
|
|
|
|
|
|
|
|
|
|
curform.find("[datatype]").each(function() {
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤;
|
|
|
|
|
if (flg) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD>dataIgnore<72>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤;
|
|
|
|
|
if (settings.ignoreHidden && $(this).is(":hidden") || $(this).data("dataIgnore") === "dataIgnore") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var inputval = Validform.util.getValue.call(curform, $(this)),
|
|
|
|
|
_this;
|
|
|
|
|
errorobj = _this = $(this);
|
|
|
|
|
|
|
|
|
|
inflag = Validform.util.regcheck.call(curform, $(this).attr("datatype"), inputval, $(this));
|
|
|
|
|
|
|
|
|
|
if (!inflag.passed) {
|
|
|
|
|
_this.addClass("Validform_error");
|
|
|
|
|
Validform.util.showmsg.call(curform, inflag.info, settings.tiptype, { obj: $(this), type: inflag.type, sweep: settings.tipSweep });
|
|
|
|
|
|
|
|
|
|
if (!settings.showAllError) {
|
|
|
|
|
_this.focus();
|
|
|
|
|
flag = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flag && (flag = false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($(this).attr("ajaxurl")) {
|
|
|
|
|
if (this.validform_valid !== "true") {
|
|
|
|
|
var thisobj = $(this);
|
|
|
|
|
_this.addClass("Validform_error");
|
|
|
|
|
Validform.util.showmsg.call(curform, curform.data("tipmsg").v || tipmsg.v, settings.tiptype, { obj: thisobj, type: 3, sweep: settings.tipSweep });
|
|
|
|
|
if (!msghidden || settings.tiptype != 1) {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
thisobj.trigger("blur", ["postform"]); //continue the form post;
|
|
|
|
|
}, 1500);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!settings.showAllError) {
|
|
|
|
|
flag = false;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flag && (flag = false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Validform.util.showmsg.call(curform, inflag.info, settings.tiptype, { obj: $(this), type: inflag.type, sweep: settings.tipSweep }, "hide");
|
|
|
|
|
_this.removeClass("Validform_error");
|
|
|
|
|
errorobj = null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (settings.showAllError) {
|
|
|
|
|
curform.find(".Validform_error:first").focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
|
|
|
|
var beforeSubmit = settings.beforeSubmit && settings.beforeSubmit(curform);
|
|
|
|
|
if (beforeSubmit === false) { return false; }
|
|
|
|
|
|
|
|
|
|
curform[0].validform_status = "posting";
|
|
|
|
|
|
|
|
|
|
if (settings.ajaxPost || ajaxPost === "ajaxPost") {
|
|
|
|
|
Validform.util.showmsg.call(curform, curform.data("tipmsg").p || tipmsg.p, settings.tiptype, { obj: curform, type: 1, sweep: settings.tipSweep }, "alwaysshow"); //<2F><><EFBFBD><EFBFBD>"alwaysshow"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ܵ<F2B2BBB9>ǰtiptyeΪ1<CEAA><31><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
curform[0].validform_ajax = $.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
async: sync,
|
|
|
|
|
url: curform.attr("action"),
|
|
|
|
|
//data: decodeURIComponent(curform.serialize(),true),
|
|
|
|
|
data: curform.serializeArray(),
|
|
|
|
|
success: function(data) {
|
|
|
|
|
if (data.status === "y") {
|
|
|
|
|
Validform.util.showmsg.call(curform, data.info, settings.tiptype, { obj: curform, type: 2, sweep: settings.tipSweep }, "alwaysshow");
|
|
|
|
|
} else {
|
|
|
|
|
curform[0].posting = false;
|
|
|
|
|
Validform.util.showmsg.call(curform, data.info, settings.tiptype, { obj: curform, type: 3, sweep: settings.tipSweep }, "alwaysshow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings.callback && settings.callback(data);
|
|
|
|
|
|
|
|
|
|
curform[0].validform_status = "posted";
|
|
|
|
|
curform[0].validform_ajax = null;
|
|
|
|
|
},
|
|
|
|
|
error: function(data) {
|
|
|
|
|
var msg = data.statusText === "abort" ?
|
|
|
|
|
curform.data("tipmsg").abort || tipmsg.abort :
|
|
|
|
|
curform.data("tipmsg").err || tipmsg.err;
|
|
|
|
|
|
|
|
|
|
curform[0].posting = false;
|
|
|
|
|
Validform.util.showmsg.call(curform, msg, settings.tiptype, { obj: curform, type: 3, sweep: settings.tipSweep }, "alwaysshow");
|
|
|
|
|
curform[0].validform_status = "normal";
|
|
|
|
|
curform[0].validform_ajax = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (!settings.postonce) {
|
|
|
|
|
curform[0].validform_status = "normal";
|
|
|
|
|
}
|
|
|
|
|
return settings.callback && settings.callback(curform);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resetForm: function() {
|
|
|
|
|
var brothers = this;
|
|
|
|
|
brothers.each(function() {
|
|
|
|
|
this.reset();
|
|
|
|
|
this.validform_status = "normal";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
brothers.find(".Validform_right").text("");
|
|
|
|
|
brothers.find(".passwordStrength").children().removeClass("bgStrength");
|
|
|
|
|
brothers.find(".Validform_checktip").removeClass("Validform_wrong Validform_right Validform_loading");
|
|
|
|
|
brothers.find(".Validform_error").removeClass("Validform_error");
|
|
|
|
|
brothers.find("[datatype]").removeData("cked").removeData("dataIgnore");
|
|
|
|
|
brothers.eq(0).find("input:first").focus();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
abort: function() {
|
|
|
|
|
if (this.validform_ajax) {
|
|
|
|
|
this.validform_ajax.abort();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.Datatype = Validform.util.dataType;
|
|
|
|
|
|
|
|
|
|
Validform.prototype = {
|
|
|
|
|
dataType: Validform.util.dataType,
|
|
|
|
|
|
|
|
|
|
eq: function(n) {
|
|
|
|
|
var obj = this;
|
|
|
|
|
|
|
|
|
|
if (n >= obj.forms.length) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(n in obj.objects)) {
|
|
|
|
|
obj.objects[n] = new Validform($(obj.forms[n]).get(), obj.settings, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return obj.objects[n];
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resetStatus: function() {
|
|
|
|
|
var obj = this;
|
|
|
|
|
$(obj.forms).each(function() {
|
|
|
|
|
this.validform_status = "normal";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setStatus: function(status) {
|
|
|
|
|
var obj = this;
|
|
|
|
|
$(obj.forms).each(function() {
|
|
|
|
|
this.validform_status = status || "posting";
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getStatus: function() {
|
|
|
|
|
var obj = this;
|
|
|
|
|
var status = $(obj.forms)[0].validform_status;
|
|
|
|
|
return status;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ignore: function(selector) {
|
|
|
|
|
var obj = this;
|
|
|
|
|
$(obj.forms).find(selector).each(function() {
|
|
|
|
|
$(this).data("dataIgnore", "dataIgnore").removeClass("Validform_error");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
unignore: function(selector) {
|
|
|
|
|
var obj = this;
|
|
|
|
|
$(obj.forms).find(selector).each(function() {
|
|
|
|
|
$(this).removeData("dataIgnore");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
addRule: function(rule) {
|
|
|
|
|
/*
|
|
|
|
|
rule => [{
|
|
|
|
|
ele:"#id",
|
|
|
|
|
datatype:"*",
|
|
|
|
|
errormsg:"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>֣<EFBFBD>",
|
|
|
|
|
nullmsg:"Ϊ<><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>֣<EFBFBD>",
|
|
|
|
|
tip:"Ĭ<><C4AC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>",
|
|
|
|
|
altercss:"gray",
|
|
|
|
|
ignore:"ignore",
|
|
|
|
|
ajaxurl:"valid.php",
|
|
|
|
|
recheck:"password",
|
|
|
|
|
plugin:"passwordStrength"
|
|
|
|
|
},{},{},...]
|
|
|
|
|
*/
|
|
|
|
|
var obj = this;
|
|
|
|
|
var rule = rule || [];
|
|
|
|
|
|
|
|
|
|
for (var index in rule) {
|
|
|
|
|
var o = $(obj.forms).find(rule[index].ele);
|
|
|
|
|
for (var attr in rule[index]) {
|
|
|
|
|
attr !== "ele" && o.attr(attr, rule[index][attr]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ajaxPost: function(flag, sync) {
|
|
|
|
|
var obj = this;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>pop box;
|
|
|
|
|
if (obj.settings.tiptype == 1 || obj.settings.tiptype == 2) {
|
|
|
|
|
creatMsgbox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Validform.util.submitForm.call($(obj.forms[0]), obj.settings, flag, "ajaxPost", sync);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submitForm: function(flag) {
|
|
|
|
|
/*flag===trueʱ<65><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ֤<D6A4><D6B1><EFBFBD>ύ*/
|
|
|
|
|
|
|
|
|
|
var obj = this;
|
|
|
|
|
|
|
|
|
|
//<2F>øö<C3B8><C3B6><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ;
|
|
|
|
|
var subflag = Validform.util.submitForm.call($(obj.forms[0]), obj.settings, flag);
|
|
|
|
|
subflag === undef && (subflag = true);
|
|
|
|
|
if (subflag === true) {
|
|
|
|
|
obj.forms[0].submit();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resetForm: function() {
|
|
|
|
|
var obj = this;
|
|
|
|
|
Validform.util.resetForm.call($(obj.forms));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
abort: function() {
|
|
|
|
|
var obj = this;
|
|
|
|
|
$(obj.forms).each(function() {
|
|
|
|
|
Validform.util.abort.call(this);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
check: function(selector, bool) {
|
|
|
|
|
/*
|
|
|
|
|
bool<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>ⲻ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Ϣ;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var selector = selector || "[datatype]",
|
|
|
|
|
obj = this,
|
|
|
|
|
curform = $(obj.forms),
|
|
|
|
|
flag = true;
|
|
|
|
|
|
|
|
|
|
curform.find(selector).each(function() {
|
|
|
|
|
Validform.util.check.call(this, curform, obj, "", bool) || (flag = false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.fn.Validform = function(settings) {
|
|
|
|
|
return new Validform(this, settings);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function setCenter(obj, time) {
|
|
|
|
|
var left = ($(window).width() - obj.outerWidth()) / 2,
|
|
|
|
|
top = ($(window).height() - obj.outerHeight()) / 2,
|
|
|
|
|
|
|
|
|
|
top = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + (top > 0 ? top : 0);
|
|
|
|
|
|
|
|
|
|
obj.css({
|
|
|
|
|
left: left
|
|
|
|
|
}).animate({
|
|
|
|
|
top: top
|
|
|
|
|
}, { duration: time, queue: false });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creatMsgbox() {
|
|
|
|
|
if ($("#Validform_msg").length !== 0) { return false; }
|
|
|
|
|
msgobj = $('<div id="Validform_msg"><div class="Validform_title">' + tipmsg.tit + '<a class="Validform_close" href="javascript:void(0);">χ</a></div><div class="Validform_info"></div><div class="iframe"><iframe frameborder="0" scrolling="no" height="100%" width="100%"></iframe></div></div>').appendTo("body"); //<2F><>ʾ<EFBFBD><CABE>Ϣ<EFBFBD><CFA2>;
|
|
|
|
|
msgobj.find("a.Validform_close").click(function() {
|
|
|
|
|
msgobj.hide();
|
|
|
|
|
msghidden = true;
|
|
|
|
|
if (errorobj) {
|
|
|
|
|
errorobj.focus().addClass("Validform_error");
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}).focus(function() { this.blur(); });
|
|
|
|
|
|
|
|
|
|
$(window).bind("scroll resize", function() {
|
|
|
|
|
!msghidden && setCenter(msgobj, 400);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>ʾ&<26>ر<EFBFBD><D8B1><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ<EFBFBD><CABE>;
|
|
|
|
|
$.Showmsg = function(msg) {
|
|
|
|
|
creatMsgbox();
|
|
|
|
|
Validform.util.showmsg.call(win, msg, 1, {});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$.Hidemsg = function() {
|
|
|
|
|
msgobj.hide();
|
|
|
|
|
msghidden = true;
|
|
|
|
|
};
|
|
|
|
|
$.ShowConfirm = function() {
|
|
|
|
|
creatMsgbox();
|
|
|
|
|
Validform.util.showConfirm.call(win, arguments[0]);
|
|
|
|
|
};
|
|
|
|
|
$.HideConfirm = function() {
|
|
|
|
|
msgobj.hide();
|
|
|
|
|
msghidden = true;
|
|
|
|
|
};
|
|
|
|
|
})(jQuery, window);
|