Bonjour !!
Comment mettre un test sur des champs indiqués par une etoile
N°
Date
et en cas d'erreur à la validation du formulaire indiqué en haut du formualire les erreurs rencontrées.
Merci
Bonjour !!
Comment mettre un test sur des champs indiqués par une etoile
N°
Date
et en cas d'erreur à la validation du formulaire indiqué en haut du formualire les erreurs rencontrées.
Merci
Il y a exactement ce que tu veux ici :
http://www.phppatterns.com/docs/design/strategy_pattern?s=validator
Bé....Merci !! Mais moi j'ai juste un mailà tester et des valeur rempli.
Pas de password, de longueur de login.
Vous me direz ! Supprime ce qui ne vas pas.
Le truc c'est que je ne sais pas trop où placer le code.
Merci
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338 <form name="Formulaire_Mail" action="EnvoiMail.php" method="post"> <table width="853" height="931" id="tabGeneral"> <tr> <td height="72" colspan="4" class="GrosTitredePageGris"><div align="left">Nos Services en ligne </div></td> </tr> <tr> <td width="73" height="40" align="center" valign="top"> <p align="left" class="InfosSites"> </p> </td> <td width="244" align="center" valign="top"> <label> <div align="left"> <input type="radio" name="optChoix" value="radiobutton" /> <span class="InfosSites">Devis</span></div> </label> </td> <td width="520" align="center" valign="top"> <label> <div align="left"> <input type="radio" name="optChoix" value="radiobutton" /> <span class="InfosSites">Commande</span><span class="Style1"> *</span></div> </label> </td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="LienImportant"><div align="left">Vous</div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"> <label> <div align="left">Client chez : </div> </label> </td> <td align="center" valign="top"><div align="left"> <select name="cmbClient" size="1" id="cmbClient"> <option>OUI</option> <option>NON</option> </select> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Numéro Client :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtNum" type="text" id="txtNum" maxlength="6" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Société :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtSociete" type="text" id="txtSociete" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Nom :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtNom" type="text" id="txtNom" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Prénom :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtPrenom" type="text" id="txtPrenom" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>E-mail :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtMail" type="text" id="txtMail" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left">Adresse : </div></td> <td align="center" valign="top"><div align="left"> <input name="txtAdresse" type="text" id="txtAdresse" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left">Code Postal : </div></td> <td align="center" valign="top"><div align="left"> <input name="txtCP" type="text" id="txtCP" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Ville :</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtVille" type="text" id="txtVille" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Téléphone :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtTelephone" type="text" id="txtTelephone" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Votre véhicule </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Numéro de Série du Type (G)</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbNumSerie" id="cmbNumSerie"> <option selected="selected">WDB</option> <option>WDC</option> <option>VSA</option> <option>WDF</option> </select> <input name="txtNumSerie" type="text" id="txtNumSerie" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Date de 1ère mise en circulation :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtMiseEnCircu" type="text" id="txtMiseEnCircu" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Produits</div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes1" type="text" id="txtDes1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence :</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef1" id="cmbRef1"> <option selected="selected">- - -</option> <option>Ma</option> <option>Mercedes</option> </select> <input name="txtRef1" type="text" id="txtRef1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte1" type="text" id="txtQte1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes2" type="text" id="txtDes2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence : </label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef2" id="cmbRef2"> <option selected="selected">- - -</option> <option>Ma</option> <option>Mercedes</option> </select> <input name="txtRef2" type="text" id="txtRef2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte2" type="text" id="txtQte2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes3" type="text" id="txtDes3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence : </label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef3" id="cmbRef3"> <option selected="selected">- - -</option> <option>Ma</option> <option>Mercedes</option> </select> <input name="txtRef3" type="text" id="txtRef3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte3" type="text" id="txtQte3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="TextedePage">Pour plus de 3 pièces, merci de nous contacter par téléphone ou de laisser un commentaire ... </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"> <label> <textarea name="txtCommentaire" id="txtCommentaire"></textarea> </label> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"> <div align="center"> <input name="cmdReinitialiser" type="reset" id="cmdReinitialiser" value="Reinitialiser" /> <input name="cmdEnvoyer" type="submit" id="cmdEnvoyer" value="Envoyer"/> </div> </div></td> </tr> </table> </form>
il te suffit d adapter a ton code
Alunissage : Procédé technique consistant à déposer des imbéciles sur un rêve enfantin.
Cours | FAQ | Sources Javascript
Cours | FAQ | Sources PHP
Mes Articles
Merci :oEnvoyé par siddh
Voilà ou j'en suis et aucune erreur sur le champs mail en le laissant vide
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364 <?php if ( $_POST['register'] ) { require_once('TestFormulaire.php'); // Register the subclasses to use $v['e']=new ValidateEmail($_POST['txtMail']); // Perform each validation foreach($v as $validator) { if (!$validator->isValid()) { while ($error=$validator->getError()) { $errorMsg.="<li>".$error."</li>\n"; } } } if (isset($errorMsg)) { print ("<p>There were errors:<ul>\n".$errorMsg."</ul>"); } else { print ('<h2>Form Valid!</h2>'); } } else { ?> <form name="Formulaire_Mail" action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="post"> <table width="95%" height="931" id="tabGeneral"> <tr> <td height="72" colspan="4" class="GrosTitredePageGris"><div align="left" class="GrosTitredePageRouge">Nos Services en ligne </div></td> </tr> <tr> <td width="73" height="40" align="center" valign="top"> <p align="left" class="InfosSites"> </p> </td> <td width="244" align="center" valign="top"> <label> <div align="left"> <input type="radio" name="optChoix" value="radiobutton" /> <span class="InfosSites">Devis</span></div> </label> </td> <td width="520" align="center" valign="top"> <label> <div align="left"> <input type="radio" name="optChoix" value="radiobutton" /> <span class="InfosSites">Commande</span><span class="Style1"> *</span></div> </label> </td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="LienImportant"><div align="left">Vous</div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"> <label> <div align="left">Client chez Mannespièces / Mannesfrance : </div> </label> </td> <td align="center" valign="top"><div align="left"> <select name="cmbClient" size="1" id="cmbClient"> <option>OUI</option> <option>NON</option> </select> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Numéro Client :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtNum" type="text" id="txtNum" maxlength="6" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Société :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtSociete" type="text" id="txtSociete" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Nom :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtNom" type="text" id="txtNom" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Prénom :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtPrenom" type="text" id="txtPrenom" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>E-mail :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtMail" type="text" id="txtMail" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left">Adresse : </div></td> <td align="center" valign="top"><div align="left"> <input name="txtAdresse" type="text" id="txtAdresse" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left">Code Postal : </div></td> <td align="center" valign="top"><div align="left"> <input name="txtCP" type="text" id="txtCP" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Ville :</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtVille" type="text" id="txtVille" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Téléphone :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtTelephone" type="text" id="txtTelephone" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Votre véhicule </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Numéro de Série du Type (G)</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbNumSerie" id="cmbNumSerie"> <option selected="selected">WDB</option> <option>WDC</option> <option>VSA</option> <option>WDF</option> </select> <input name="txtNumSerie" type="text" id="txtNumSerie" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Date de 1ère mise en circulation :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtMiseEnCircu" type="text" id="txtMiseEnCircu" /> <span class="Style1">*</span></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Produits</div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes1" type="text" id="txtDes1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence :</label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef1" id="cmbRef1"> <option selected="selected">- - -</option> <option>;ces</option> <option>Mercedes</option> </select> <input name="txtRef1" type="text" id="txtRef1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité :</label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte1" type="text" id="txtQte1" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes2" type="text" id="txtDes2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence : </label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef2" id="cmbRef2"> <option selected="selected">- - -</option> <option>;ces</option> <option>Mercedes</option> </select> <input name="txtRef2" type="text" id="txtRef2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte2" type="text" id="txtQte2" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Désignation : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtDes3" type="text" id="txtDes3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Référence : </label> <label></label> </div></td> <td align="center" valign="top"><div align="left"> <select name="cmbRef3" id="cmbRef3"> <option selected="selected">- - -</option> <option>Ma;ces</option> <option>Mercedes</option> </select> <input name="txtRef3" type="text" id="txtRef3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td align="center" valign="top" class="TextedePage"><div align="left"> <label>Quantité : </label> </div></td> <td align="center" valign="top"><div align="left"> <input name="txtQte3" type="text" id="txtQte3" /> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left" class="TextedePage">Pour plus de 3 pièces, merci de nous contacter par téléphone ou de laisser un commentaire ... </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"> <label> <textarea name="txtCommentaire" id="txtCommentaire"></textarea> </label> </div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"></div></td> </tr> <tr> <td height="21" align="center" valign="top"> </td> <td colspan="2" align="center" valign="top"><div align="left"> <div align="center"> <input name="cmdReinitialiser" type="reset" id="cmdReinitialiser" value="Reinitialiser" /> <input name="cmdEnvoyer" type="submit" id="cmdEnvoyer" value="Envoyer"/> </div> </div></td> </tr> </table> </form> <?php } ?>
TEST FORUMAIRE
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 <?php /** * Validator superclass for form validation */ class Validator { /** * Private * $errorMsg stores error messages if not valid */ var $errorMsg; //! A constructor. /** * Constucts a new Validator object */ function Validator () { $this->errorMsg=array(); $this->validate(); } //! A manipulator /** * @return void */ function validate() { // Superclass method does nothing } //! A manipulator /** * Adds an error message to the array * @return void */ function setError ($msg) { $this->errorMsg[]=$msg; } //! An accessor /** * Returns true is string valid, false if not * @return boolean */ function isValid () { if ( isset ($this->errorMsg) ) { return false; } else { return true; } } //! An accessor /** * Pops the last error message off the array * @return string */ function getError () { return array_pop($this->errorMsg); } } /** * ValidatorUser subclass of Validator * Validates a username */ class ValidateUser extends Validator { /** * Private * $user the username to validate */ var $user; //! A constructor. /** * Constucts a new ValidateUser object * @param $user the string to validate */ function ValidateUser ($user) { $this->user=$user; Validator::Validator(); } //! A manipulator /** * Validates a username * @return void */ function validate() { if (!preg_match('/^[a-zA-Z0-9_]+$/',$this->user )) { $this->setError('Username contains invalid characters'); } if (strlen($this->user) < 6 ) { $this->setError('Username is too short'); } if (strlen($this->user) > 20 ) { $this->setError('Username is too long'); } } } /** * ValidatorPassword subclass of Validator * Validates a password */ class ValidatePassword extends Validator { /** * Private * $pass the password to validate */ var $pass; /** * Private * $conf to confirm the passwords match */ var $conf; //! A constructor. /** * Constucts a new ValidatePassword object subclass or Validator * @param $pass the string to validate * @param $conf to compare with $pass for confirmation */ function ValidatePassword ($pass,$conf) { $this->pass=$pass; $this->conf=$conf; Validator::Validator(); } //! A manipulator /** * Validates a password * @return void */ function validate() { if ($this->pass!=$this->conf) { $this->setError('Passwords do not match'); } if (!preg_match('/^[a-zA-Z0-9_]+$/',$this->pass )) { $this->setError('Password contains invalid characters'); } if (strlen($this->pass) < 6 ) { $this->setError('Password is too short'); } if (strlen($this->pass) > 20 ) { $this->setError('Password is too long'); } } } /** * ValidatorEmail subclass of Validator * Validates an email address */ class ValidateEmail extends Validator { /** * Private * $email the email address to validate */ var $email; //! A constructor. /** * Constucts a new ValidateEmail object subclass or Validator * @param $email the string to validate */ function ValidateEmail ($email){ $this->email=$email; Validator::Validator(); } //! A manipulator /** * Validates an email address * @return void */ function validate() { $pattern= "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/"; if(!preg_match($pattern,$this->email)){ $this->setError('Invalid email address'); } if (strlen($this->email)>100){ $this->setError('Address is too long'); } } } ?>
Tiens, rajoute ceci dans tes validators :
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 class ValidateRequired extends Validator { var $name; var $value; function ValidateRequired ($name, $value) { $this->name=$name; $this->value=$value; Validator::Validator(); } function validate() { if (trim($this->value) == '' )) { $this->setError($name.' is required !'); } } }
Puis dans ton formulaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <?php if ( $_POST['register'] ) { require_once('TestFormulaire.php'); // Register the subclasses to use $v['er']=new ValidateRequired('email', $_POST['txtMail']); $v['e'] =new ValidateEmail($_POST['txtMail']); ...
Proposition comme une autre, non testée donc à toi de nous dire !
c'est pas plus simple demattre du JS?
(g po lut c trop long ^^ dsl si je dit des conneries)
C'est pas plus simple c'est une option, en gros la validation doit se faire côté serveur. Puis si t'es sympa avec tes utilisateurs tu leur économises du temps de la bande passante en pre-validant côté client.
Regle d'or: ne jamais avoir une confiance aveugle dans la validité des données qui proviennent du client.
Je sais pas si ma phrase est bien tournée mais je me comprend, c'est l'essentiel
ok, j'ai ruien lut, j'aurais pas dut ^^
je pensait qu'il utilisait HTML_quickform ou un truc du genre
m'enfin validation coté client ET serveutr c'est long mais c'est mieux
tout le monde est pas forcement tres doué en informtaique... faut s'en souvenir : on progrmme pas pour soi
Pas encoreEnvoyé par hansaplast
Envoyé par Mr N.
Il ne se passe rien.
Pas le message d'erreur qui s'affiche... :
Dans le nouveau validator, remplace la fonction validate par celle ci :
Ca donne koi ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 function validate() { var_dump('#'.$this->value.'#'); if (trim($this->value) == '' )) { $this->setError($name.' is required !'); } }
IDEM !!!Envoyé par Mr N.
Voilà mon validator (au cas ou j'ai fait une erreur)
MERCI
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 <?php /** * Validator superclass for form validation */ class Validator { /** * Private * $errorMsg stores error messages if not valid */ var $errorMsg; //! A constructor. /** * Constucts a new Validator object */ function Validator () { $this->errorMsg=array(); $this->validate(); } //! A manipulator /** * @return void */ function validate() { // Superclass method does nothing } //! A manipulator /** * Adds an error message to the array * @return void */ function setError ($msg) { $this->errorMsg[]=$msg; } //! An accessor /** * Returns true is string valid, false if not * @return boolean */ function isValid () { if ( isset ($this->errorMsg) ) { return false; } else { return true; } } //! An accessor /** * Pops the last error message off the array * @return string */ function getError () { return array_pop($this->errorMsg); } } /** * ValidatorUser subclass of Validator * Validates a username */ class ValidateUser extends Validator { /** * Private * $user the username to validate */ var $user; //! A constructor. /** * Constucts a new ValidateUser object * @param $user the string to validate */ function ValidateUser ($user) { $this->user=$user; Validator::Validator(); } //! A manipulator /** * Validates a username * @return void */ function validate() { if (!preg_match('/^[a-zA-Z0-9_]+$/',$this->user )) { $this->setError('Username contains invalid characters'); } if (strlen($this->user) < 6 ) { $this->setError('Username is too short'); } if (strlen($this->user) > 20 ) { $this->setError('Username is too long'); } } } /** * ValidatorPassword subclass of Validator * Validates a password */ class ValidatePassword extends Validator { /** * Private * $pass the password to validate */ var $pass; /** * Private * $conf to confirm the passwords match */ var $conf; //! A constructor. /** * Constucts a new ValidatePassword object subclass or Validator * @param $pass the string to validate * @param $conf to compare with $pass for confirmation */ function ValidatePassword ($pass,$conf) { $this->pass=$pass; $this->conf=$conf; Validator::Validator(); } //! A manipulator /** * Validates a password * @return void */ function validate() { if ($this->pass!=$this->conf) { $this->setError('Passwords do not match'); } if (!preg_match('/^[a-zA-Z0-9_]+$/',$this->pass )) { $this->setError('Password contains invalid characters'); } if (strlen($this->pass) < 6 ) { $this->setError('Password is too short'); } if (strlen($this->pass) > 20 ) { $this->setError('Password is too long'); } } } /** * ValidatorEmail subclass of Validator * Validates an email address */ class ValidateEmail extends Validator { /** * Private * $email the email address to validate */ var $email; //! A constructor. /** * Constucts a new ValidateEmail object subclass or Validator * @param $email the string to validate */ function ValidateEmail ($email){ $this->email=$email; Validator::Validator(); } //! A manipulator /** * Validates an email address * @return void */ function validate() { $pattern= "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/"; if(!preg_match($pattern,$this->email)){ $this->setError('Invalid email address'); } if (strlen($this->email)>100){ $this->setError('Address is too long'); } } } class ValidateRequired extends Validator { var $name; var $value; function ValidateRequired ($name, $value) { $this->name=$name; $this->value=$value; Validator::Validator(); } function validate() { var_dump('#'.$this->value.'#'); if (trim($this->value) == '' )) { $this->setError($name.' is required !'); } } } ?>
Et, juste pour être sur, le code de validation du formulaire ?
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 <?php if ( $_POST['register'] ) { require_once('TestFormulaire.php'); // Register the subclasses to use $v['er']=new ValidateRequired('email', $_POST['txtMail']); $v['e']=new ValidateEmail($_POST['txtMail']); // Perform each validation foreach($v as $validator) { if (!$validator->isValid()) { while ($error=$validator->getError()) { $errorMsg.="<li>".$error."</li>\n"; } } } if (isset($errorMsg)) { print ("<p>There were errors:<ul>\n".$errorMsg."</ul>"); } else { print ('<h2>Form Valid!</h2>'); } } else { ?> <form name="Formulaire_Mail" action="<?php echo ($_SERVER['PHP_SELF']); ?>" method="post"> .................................................. ..................... ................................. </form> <?php } ?>
Ouf, un moment j'ai cru que tu allais tout me mettre
Ajoute ceci dans ton formulaire (a coté d'un bouton submit par exemple)
Pour voir si ca change qq chose...
Code : Sélectionner tout - Visualiser dans une fenêtre à part <input type="hidden" name="register" value="1" />
Là tout disparait a part mon fond d'écran !!! :Envoyé par Mr N.
Thanks
J'ai pas compris ce qui c'est passé ? windows a planté ???
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager