Bonjour à tous,

alors voilà mon soucis, je voudrais pouvoir passer en argument d'une fonction une regex de ce type (/^[a-zéèëêàäâùüûöôïïüûç-]{1,15}$/i) testé avec et sans guillemet mais ca marche pas (code - 1).puis comme il peut y en avoir plusieur je les passe en setAttributes(arg[xi]), (code -2, ligne 148 à 156) pour les récupérer avec this.getAttribute à l'interieur de la fonction addeventsimple (code -2, ligne 231) avec un match. Sauf qu'à la fin et bien aucun contrôle ne passe losrque je l'utilise dans match, alert 2 se déclenche à chaque coup.
appel de ma fonction
code - 1
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
form_ctrl_info('mc_ad_inputb_8','centralisation',38,-10,1,15,'1 à 15 caractères','Lettres avec/sans accent','/^[a-zéèëêàäâùüûöôïïüûç-]{1,15}$/i');
la Fonction qui elle va faire appel à la fonction addeventsimple
code - 2
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
 
/*
	les arguments par ordre
	0 = id de l input (varchar)
	1 = id de la balise dans laquel la position absolute sera prise en compte (varchar)
	2 = l'espacement à droite de l'infobulle par rapport à l'input (-x,+x)
	3 = l'espacement par rapport au top de l'input (-x,+x)
	4 = nombre minimum de caractères si 0 non-obligatoire
	5 = nombre maximum de caractères si 0 infinité de caractères
	6,8,10(pair) = descriptif du contrôle
	7,9,11(impair) = regex associé sau descriptif
	*/
	function form_ctrl_info() 
	{
		array_arg = new Array();
		array_arg = form_ctrl_info.arguments;
		//l argument 0 sera l id de l'input
		id = array_arg[0];
		if(document.getElementById(id))
		{
			//on crée l'infobulle qui apparaitra
			// div_conteneur le conteneur
			div_conteneur = document.createElement('div');
			div_conteneur.id = array_arg[0]+'_ctn';
			div_conteneur.style.display = 'none';
			div_conteneur.style.width = '250px';
			div_conteneur.style.height = '100px';  
			div_conteneur.style.position = 'absolute';   
 
			left = document.getElementById(id).offsetLeft+document.getElementById(id).offsetWidth+array_arg[2];
			div_conteneur.style.left = left+'px';
 
			top2 = document.getElementById(id).offsetTop+array_arg[3];
			div_conteneur.style.top = top2+'px';  
			div_conteneur.style.zPosition = '100';
 
			//header
			div_header = document.createElement('div');
			div_header.style.width = '250px';
			div_header.style.height = '5px';  
			div_header.style.background = 'url(image/cadre/info_cadre_form_header.png) no-repeat'; 
			div_header.style.cssFloat = 'left';    
			div_conteneur.appendChild(div_header);	
 
			//body
			div_body = document.createElement('div');
			div_body.style.width = '250px';
			div_body.style.background = 'url(image/cadre/info_cadre_form_body.png)  repeat-y'; 
			div_body.style.cssFloat = 'left';    
			div_conteneur.appendChild(div_body);	
 
			//foot
			div_foot = document.createElement('div');
			div_foot.style.width = '250px';
			div_foot.style.height = '5px';  
			div_foot.style.background = 'url(image/cadre/info_cadre_form_foot.png)  no-repeat'; 
			div_foot.style.cssFloat= 'left';    
			div_conteneur.appendChild(div_foot);
 
			//on inclut la div dans l'id indiqué (display none)
			document.getElementById(array_arg[1]).appendChild(div_conteneur);
 
			//on met si les deux ne sont pas à 0
			i=1;
			div_body_1_ = new Array();
			div_body_2_ = new Array();
			img_1_ = new Array();
			img_2_ = new Array();
			if((array_arg[4]!=0)&&(array_arg[5]!=0))
			{
				//body_2
				div_body_2_[i] = document.createElement('div');
				div_body_2_[i].style.width = '15px';
				div_body_2_[i].style.paddingLeft = '2px';
				div_body_2_[i].style.height = '17px';
				div_body_2_[i].style.marginTop = '3px';
				div_body_2_[i].style.cssFloat = 'left'; 
				div_body.appendChild(div_body_2_[i]);
 
				//body_1
				div_body_1_[i] = document.createElement('div');
				div_body_1_[i].style.width = '228px';
				div_body_1_[i].style.paddingLeft = '3px';
				div_body_1_[i].style.paddingRight = '2px';
				div_body_1_[i].style.height = '20px';
				div_body_1_[i].style.cssFloat = 'left'; 
				div_body_1_[i].innerHTML = array_arg[6];
				div_body.appendChild(div_body_1_[i]);	
 
 
				//img dans body 2
				img_1_[i] = document.createElement('img');
				img_1_[i].src = 'image/moncompte/cross.png';
				img_1_[i].id = array_arg[0]+'_img_1_'+[i];
				img_1_[i].style.display = 'block'; 
				div_body_2_[i].appendChild(img_1_[i]);
 
				img_2_[i] = document.createElement('img');
				img_2_[i].src = 'image/moncompte/vu.png';
				img_2_[i].id = array_arg[0]+'_img_2_'+[i];
				img_2_[i].style.display = 'none'; 
				div_body_2_[i].appendChild(img_2_[i]);
			}
			i++;
			yx=7;
			while(array_arg[yx])
			{
				//body_2
				div_body_2_[i] = document.createElement('div');
				div_body_2_[i].style.width = '15px';
				div_body_2_[i].style.paddingLeft = '2px';
				div_body_2_[i].style.height = '17px';
				div_body_2_[i].style.marginTop = '3px';
				div_body_2_[i].style.cssFloat = 'left'; 
				div_body.appendChild(div_body_2_[i]);
 
				//body_1
				div_body_1_[i] = document.createElement('div');
				div_body_1_[i].style.width = '228px';
				div_body_1_[i].style.paddingLeft = '3px';
				div_body_1_[i].style.paddingRight = '2px';
				div_body_1_[i].style.height = '20px';
				div_body_1_[i].style.cssFloat = 'left'; 
				div_body_1_[i].innerHTML = array_arg[yx];
				div_body.appendChild(div_body_1_[i]);	
 
 
				//img dans body 2
				img_1_[i] = document.createElement('img');
				img_1_[i].src = 'image/moncompte/cross.png';
				img_1_[i].id = array_arg[0]+'_img_1_'+[i];
				img_1_[i].style.display = 'block'; 
				div_body_2_[i].appendChild(img_1_[i]);
 
				img_2_[i] = document.createElement('img');
				img_2_[i].src = 'image/moncompte/vu.png';
				img_2_[i].id = array_arg[0]+'_img_2_'+[i];
				img_2_[i].style.display = 'none'; 
				div_body_2_[i].appendChild(img_2_[i]);
 
				yx=yx+2;
				i++;
			}
			//controle si les conditions ont été accéptées
			input_value_agreed = new Array();
			//transmet les infos en attribut de la div pour povuoir les exploiter dans la fonction addeventsimple
			document.getElementById(id).indice_1 = array_arg[0];
			// le code regex
			xi=8;
			xy=1;
			while(array_arg[xi])
			{
				document.getElementById(id).setAttribute('regex_'+xy,eval(array_arg[xi]));
 
				xy++;
				xi=xi+2;
			}
			document.getElementById(id).setAttribute('min_length',array_arg[4]);
			document.getElementById(id).setAttribute('max_length',array_arg[5]);
			addEventSimple(document.getElementById(id), 'focus', function()
			{
				document.getElementById(this.indice_1+'_ctn').style.display = 'block';
 
				if(this.value=='')
				{
					//controle la longeur
					if((this.getAttribute('min_length')!=0)&&(this.getAttribute('max_length')!=0))
					{
						input_txt_length = document.getElementById(id).value.length;
						if((input_txt_length>=this.getAttribute('min_length'))&&(input_txt_length<=this.getAttribute('max_length')))
						{
							input_value_agreed[1]=true;
							document.getElementById(this.indice_1+'_img_1_'+[1]).style.display='none';
							document.getElementById(this.indice_1+'_img_2_'+[1]).style.display='block';;
						}
						else
						{
							document.getElementById(this.indice_1+'_img_1_'+[1]).style.display='block';
							document.getElementById(this.indice_1+'_img_2_'+[1]).style.display='none';;
							input_value_agreed[1]=false;
						}
					}
					xz=1;
					//2 car 1 pour la longueur utilisé ci-dessus
					array_ctrl=2;
					while(this.getAttribute('regex_'+xz))
					{
						img_adjust = xz+1;
						ctrl=document.getElementById(id).value.match(eval(this.getAttribute('regex_'+xz)));
						if(ctrl!=null)
						{	
							input_value_agreed[array_ctrl]=true;
							document.getElementById(this.indice_1+'_img_1_'+[img_adjust]).style.display='none';
							document.getElementById(this.indice_1+'_img_2_'+[img_adjust]).style.display='block';;
						}
						else
						{
							input_value_agreed[array_ctrl]=false;
							document.getElementById(this.indice_1+'_img_1_'+[img_adjust]).style.display='block';
							document.getElementById(this.indice_1+'_img_2_'+[img_adjust]).style.display='none';;
						}					
						xz++;
						array_ctrl++;
					}
				}
			});	
			addEventSimple(document.getElementById(id), 'keyup', function()
			{
				//controle la longeur
					if((this.getAttribute('min_length')!=0)&&(this.getAttribute('max_length')!=0))
					{
						input_txt_length = document.getElementById(id).value.length;
						if((input_txt_length>=this.getAttribute('min_length'))&&(input_txt_length<=this.getAttribute('max_length')))
						{
							input_value_agreed[1]=true;
							document.getElementById(this.indice_1+'_img_1_'+[1]).style.display='none';
							document.getElementById(this.indice_1+'_img_2_'+[1]).style.display='block';;
						}
						else
						{
							document.getElementById(this.indice_1+'_img_1_'+[1]).style.display='block';
							document.getElementById(this.indice_1+'_img_2_'+[1]).style.display='none';;
							input_value_agreed[1]=false;
						}
					}
					xz=1;
					//2 car 1 pour la longueur utilisé ci-dessus
					array_ctrl=2;
					while(this.getAttribute('regex_'+xz))
					{
						img_adjust = xz+1;
						ctrl=document.getElementById(id).value.match(this.getAttribute('regex_'+xz));
						if(ctrl!=null)
						{	
							alert(1);
							input_value_agreed[array_ctrl]=true;
							document.getElementById(this.indice_1+'_img_1_'+[img_adjust]).style.display='none';
							document.getElementById(this.indice_1+'_img_2_'+[img_adjust]).style.display='block';;
						}
						else
						{
							alert(2);
							input_value_agreed[array_ctrl]=false;
							document.getElementById(this.indice_1+'_img_1_'+[img_adjust]).style.display='block';
							document.getElementById(this.indice_1+'_img_2_'+[img_adjust]).style.display='none';;
						}					
						xz++;
						array_ctrl++;
					}
			});
 
			addEventSimple(document.getElementById(id), 'blur', function()
			{
				document.getElementById(this.indice_1+'_ctn').style.display = 'none';
 
				//controle si il ya des erreur
				length = input_value_agreed.length;
				error_display_cross=false;
				for(i=1;i<=length;i++)
				{
					if(input_value_agreed[i]==false)
					{
						error_display_cross=true;
					}
				}
				if(error_display_cross==true)
				{
 
				}
				else
				{
 
				}
			});
		}
	}
la fonction addeventsimple
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
		// Compatibilité du onclik sur les différents browser
		function addEventSimple(obj,evt,fn){
			if(obj==null)
			{
				return false;
			}
			if (obj.addEventListener)
			{
				obj.addEventListener(evt,fn,false);
			}
			else if (obj.attachEvent)
			{
				obj.attachEvent('on'+evt,fn);
			}
		}
Merci à ceux qui prendront le temps de se pencher sur mon problème.