芝麻web文件管理V1.00
编辑当前文件:/home/prismawe/www/resupres/javascript/checkform.js
function CheckForm(a){this.fid=a;this.setFormulaire(a);this.formulaire=document;this.messageError=[];this.value=[];this.c=[];this.t=[];this.r=[];this.m=[];this.p=[];this.l=[];this.ol=[];this.e=[];this.tab_comp=[];this.type_comp=[];this.custom_cond=[]}CheckForm.prototype={debug:false,authorizeKeyControl:true,formLock:true,idMsg:"erreurJs",defaultLinkOperator:"==",regSeparator:":",msgElement:"p",validateColor:"#e5ff80",errorColor:"#ff5555",msgAttributes:{style:"","class":"checkform-error"},isImgDisplay:false,validateImg:"./Img/checkform-validate.png",errorImg:"./Img/checkform-error.png",casseSensitive:true,formulaire:document,messageError:[],value:[],c:[],t:[],r:[],m:[],p:[],l:[],ol:[],e:[],tab_comp:[],type_comp:[],custom_cond:[],authorized:{alpha:/^[a-z ._\-]$/i,alphanum:/^[a-z0-9 ._\-]$/i,digitSign:/^[\-+0-9]$/,digit:/^[0-9]$/,nodigit:/^[^0-9]$/,number:/^[\d\.]$/,email:/^[a-zA-Z0-9\._%@\-]$/i,phone:/^[\d\s\+\.\-]$/,url:/^[a-z0-9\-\.\/_]$/i,date:/^[0-9\s\. ]$/,hexaColor:/#[0-9a-fA-F]$/},reg:{required:/[^.*]/,alpha:/^[a-z ._\-]+$/i,alphanum:/^[a-z0-9 ._\-]+$/i,digitSign:/^[\-+]?[0-9]+$/,digit:/^[0-9]+$/i,nodigit:/^[^0-9]+$/,number:/^[\-+]?\d*\.?\d+$/,email:/^[a-z0-9._%\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$/i,phone:/^[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}[\s]{0,1}[0-9]{2}$/,url:/^(http|https):\/\/[a-z0-9\-\.\/_]+\.[a-z]{2,3}$/i,date:/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2,4}$/,hexaColor:/#[0-9a-fA-F]{6}/,notEmpty:/^(.*[^0\s].*)$/},prevKeyCode:"",keyCodeValues:{32:" ",9:"\t",13:"\n",48:"�",49:"&",50:"�",51:'"',52:"'",53:"(",54:"-",5:"�",56:"_",57:"�",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:".",111:"/",109:"-",107:"+",106:"*",186:";",187:"=",188:",",189:"-",191:"/",220:"\\",219:")",222:"'",221:"^",192:"`",190:";"},fieldModif:{field_id:"c",field_type:"t",field_reg:"r",field_msg:"m",field_event:"e",field_tab_comp:"tab_comp",field_type_comp:"type_comp",field_custom_cond:"custom_cond"},setValue:function(a,b){if(a.value!==""){this.value[b]=a.value}else{this.value[b]=""}},setFormulaire:function(a){this.formulaire=document.getElementById(a);if(this.formulaire.nodeName=="FORM"){this.addEventListener(this.formulaire,"submit",this.bind(this,this.traiteSubmit),false)}else{if(this.formulaire.nodeName=="INPUT"){this.addEventListener(this.formulaire,"click",this.bind(this,this.traiteSubmit),false)}}},setDebug:function(a){this.debug=a},setAuthorizeKeyControl:function(a){this.authorizeKeyControl=a},setFormLock:function(a){this.formLock=a},setIsImgDisplay:function(a){this.isImgDisplay=a},setIdMsg:function(a){this.idMsg=a},setDefaultLinkOperator:function(a){this.defaultLinkOperator=a},setRegSeparator:function(a){this.regSeparator=a},setMsgElement:function(a){this.msgElement=a},setValidateColor:function(a){this.validateColor=a},setErrorColor:function(a){this.errorColor=a},setMsgAttributes:function(a){this.msgAttributes=a},setCasseSensitive:function(a){this.casseSensitive=a},setElement:function(c,a,b){var d=this.getNumReg(c);if(d!==false){this[this.fieldModif[a]][d]=b}},getMessageError:function(){return this.messageError},traiteKeyCode:function(c,b){var a=null;if(typeof(this.keyCodeValues[c])!=="undefined"&&!b.shiftKey&&!b.altKey){a=this.keyCodeValues[c]}else{if(typeof(this.keyCodeValues[c])!=="undefined"&&(this.prevKeyCode==16||b.shiftKey)){switch(c){case 48:a="0";break;case 219:a="�";break;case 107:a="+";break;case 190:a=".";break;default:a=(c%48)}}else{if(typeof(this.keyCodeValues[c])!=="undefined"&&(this.prevKeyCode==18||b.altKey)){switch(c){case 48:a="@";break;case 49:a="^";break;case 50:a="~";break;case 55:a="`";break;case 52:a="|";break;case 53:a="[";break;case 54:a="{";break;case 51:a="#";break;case 56:a="\\";break;case 219:a="]";break;case 107:a="}";break;default:a=this.keyCodeValues[c]}}else{if(typeof(this.keyCodeValues[c])!=="undefined"){a=this.keyCodeValues[c]}}}}this.prevKeyCode=c;return a},traitePress:function(f,d){var b=d||window.event;if(b.keyCode==9||b.keyCode==8||b.keyCode==37||b.keyCode==38||b.keyCode==39||b.keyCode==40){return}var a=this.parseReg(this.r[f]);for(i in a){if(typeof(this.authorized[a[i]])!=="undefined"){var c=this.traiteKeyCode(b.keyCode,b);if(this.authorized[a[i]].test(c)===false&&(a[i]!="required"||c!="")){this.messageError[f]=this.m[f];break}else{delete this.messageError[f]}}}if(typeof(this.messageError[f])!=="undefined"){if(b.preventDefault){b.preventDefault()}b.returnValue=false;return false}this.validateReg(f)},traiteSubmit:function(b){this.validateReg();if(this.messageError!==""&&(this.messageError.join("")).length!==0&&this.formLock===true){var a=b||window.event;if(a.preventDefault){a.preventDefault()}a.returnValue=false;return false}},delReg:function(a){var b=this.getNumReg(a);this.removeEventListener(this.$(a),this.e[b],this.bind(this,this.validateReg,[b]),false);this.value[b]="";this.c[b]="";this.t[b]="";this.r[b]="";this.m[b]="";this.p[b]="";this.l[b]="";this.ol[b]="";this.e[b]="";this.tab_comp[b]="";this.type_comp[b]="";this.custom_cond[b]="";delete this.messageError[b];if(this.isImgDisplay===true){this.afficheMsg(b)}else{this.hiddeMsg(b)}},addReg:function(h,f,d,c,k,n,m,q,r,b,j,e){var l=this.getNumReg(h);if(l!==false){return false}if(this.$(h)!==null){this.initialise(arguments);var p=this.c.length-1;if(typeof(f)!="undefined"){if(f=="radio"||f=="checkbox"){var a=document.getElementsByName(h);for(var g=0,o=a.length;g
this.p[n]["1"]){isError=true}}if(typeof(this.t[n])!="undefined"){var tab_element=document.getElementsByName(this.c[n]);var nb_checked=0;for(var i=0,sz=tab_element.length;i
1){isError=true}}else{if(this.t[n]=="checkbox"){if(typeof(this.p[n])!="undefined"){if(nb_checked
this.p[n]["1"]){isError=true}}}}}if(typeof(this.l[n])!="undefined"){for(var i in this.l[n]){var operator=(typeof(this.ol[n])!=="undefined")?this.ol[n]:this.defaultLinkOperator;if(!eval("'"+this.value[n]+"' "+operator+" '"+this.$(this.l[n][i]).value+"'")){isError=true}}}if(typeof(this.tab_comp[n])!="undefined"){var tab_words=this.value[n].split(" ");var nb_found=0;for(var i=0,sz=this.tab_comp[n].length;i
=0){if(nb_found!=this.type_comp[n]){isError=true}}else{if(nb_found==0){isError=true}}}}if(typeof(this.custom_cond[n])!="undefined"){if(!eval("'"+this.value[n]+"' "+this.custom_cond[n])){isError=true}}if(isError){this.messageError[n]=this.m[n];this.afficheMsg(n)}else{delete this.messageError[n];if(this.isImgDisplay===true){this.afficheMsg(n)}else{this.hiddeMsg(n)}}},hiddeMsg:function(b){if(document.getElementById(this.fid+"-msg-error-"+b)===null){return false}var a=document.getElementById(this.fid+"-msg-error-"+b);a.parentNode.removeChild(a);this.colorize(b,false)},afficheMsg:function(g){this.hiddeMsg(g);var f=document.createElement(this.msgElement);f.id=this.fid+"-msg-error-"+g;var a=this.messageError[g];if(this.isImgDisplay===true){f.className="checkform-img-error";var d=document.createElement("img");d.id=this.fid+"-checkform-image-"+g;if(typeof(a)=="undefined"){d.src=this.validateImg}else{if(this.errorImg!=""){d.src=this.errorImg}}f.appendChild(d)}else{f.className="checkform-msg-error";var b=document.createTextNode(a);f.appendChild(b)}for(var c in this.msgAttributes){if(c!="undefined"){f.setAttribute(c,this.msgAttributes[c])}}if(this.idMsg!==null&&this.isImgDisplay===false){var e=this.$(this.idMsg);e.appendChild(f,e)}else{var e=this.$(this.c[g]);this.insertAfter(f,e)}this.colorize(g,true)},colorize:function(b,a){if(typeof(this.$(this.c[b]))==="undefined"){return false}if(a){this.$(this.c[b]).style.backgroundColor=this.errorColor}else{this.$(this.c[b]).style.backgroundColor=this.validateColor}},showError:function(a){if(this.debug){alert(a)}},isRequired:function(b){var a=this.parseReg(this.r[b]);if(a.length!==0){for(i in a){if(typeof(a[i])=="string"){if(a[i]=="required"){return true}}}}return false},getNumReg:function(b){for(var a=0,c=this.c.length;a