IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Test sur formulaire avec liste des erreurs


Sujet :

Langage PHP

  1. #1
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut Test sur formulaire avec liste des erreurs
    Bonjour !!

    Comment mettre un test sur des champs indiqués par une etoile


    Date
    Mail

    et en cas d'erreur à la validation du formulaire indiqué en haut du formualire les erreurs rencontrées.

    Merci

  2. #2
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Il y a exactement ce que tu veux ici :
    http://www.phppatterns.com/docs/design/strategy_pattern?s=validator

  3. #3
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div>
            </label>   </td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Votre v&eacute;hicule </div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>D&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>R&eacute;f&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>Quantit&eacute; :          </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">&nbsp;</td>
        <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>D&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>R&eacute;f&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>Quantit&eacute; :          </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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left" class="TextedePage">Pour plus de 3 pi&egrave;ces, merci de nous contacter par t&eacute;l&eacute;phone ou de laisser un commentaire ... </div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left">
     
            <div align="center">
              <input name="cmdReinitialiser" type="reset" id="cmdReinitialiser" value="Reinitialiser" />
              &nbsp;&nbsp;&nbsp;
              <input name="cmdEnvoyer" type="submit" id="cmdEnvoyer" value="Envoyer"/>
              </div>
     
        </div></td>
      </tr>
    </table>
      </form>

  4. #4
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut

  5. #5
    Expert confirmé
    Avatar de siddh
    Inscrit en
    Novembre 2005
    Messages
    3 868
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Novembre 2005
    Messages : 3 868
    Points : 5 011
    Points
    5 011
    Par défaut
    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

  6. #6
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    Citation Envoyé par siddh
    il te suffit d adapter a ton code
    Merci :o

    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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span></div>
            </label>   </td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left" class="LienImportant">Votre v&eacute;hicule </div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>D&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>R&eacute;f&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>Quantit&eacute; :          </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">&nbsp;</td>
        <td colspan="2" align="center" valign="top" class="TextedePage"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>D&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>R&eacute;f&eacute;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">&nbsp;</td>
        <td align="center" valign="top" class="TextedePage"><div align="left">
     
              <label>Quantit&eacute; :          </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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left" class="TextedePage">Pour plus de 3 pi&egrave;ces, merci de nous contacter par t&eacute;l&eacute;phone ou de laisser un commentaire ... </div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</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">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left"></div></td>
      </tr>
      <tr>
        <td height="21" align="center" valign="top">&nbsp;</td>
        <td colspan="2" align="center" valign="top"><div align="left">
     
            <div align="center">
              <input name="cmdReinitialiser" type="reset" id="cmdReinitialiser" value="Reinitialiser" />
              &nbsp;&nbsp;&nbsp;
              <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');
            }
        }
    }
    ?>

  7. #7
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    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 !

  8. #8
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    c'est pas plus simple demattre du JS?

    (g po lut c trop long ^^ dsl si je dit des conneries)

  9. #9
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    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

  10. #10
    Membre éclairé Avatar de hansaplast
    Homme Profil pro
    Artisant logiciel
    Inscrit en
    Septembre 2005
    Messages
    948
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Artisant logiciel
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 948
    Points : 719
    Points
    719
    Par défaut
    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

  11. #11
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Citation Envoyé par hansaplast
    je pensait qu'il utilisait HTML_quickform ou un truc du genre
    Pas encore

  12. #12
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    Citation Envoyé par Mr N.
    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 !

    Il ne se passe rien.

    Pas le message d'erreur qui s'affiche... :

  13. #13
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Dans le nouveau validator, remplace la fonction validate par celle ci :
    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 !');
            }
        }
    Ca donne koi ?

  14. #14
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    Citation Envoyé par Mr N.
    Dans le nouveau validator, remplace la fonction validate par celle ci :
    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 !');
            }
        }
    Ca donne koi ?
    IDEM !!!

    Voilà mon validator (au cas ou j'ai fait une erreur)
    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 !'); 
            } 
        } 
    } 
    ?>
    MERCI

  15. #15
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    Et, juste pour être sur, le code de validation du formulaire ?

  16. #16
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    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
    }
    ?>

  17. #17
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    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)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input type="hidden" name="register" value="1" />
    Pour voir si ca change qq chose...

  18. #18
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut
    Citation Envoyé par Mr N.
    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)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input type="hidden" name="register" value="1" />
    Pour voir si ca change qq chose...
    Là tout disparait a part mon fond d'écran !!! :

    Thanks

  19. #19
    Membre régulier
    Inscrit en
    Février 2003
    Messages
    219
    Détails du profil
    Informations forums :
    Inscription : Février 2003
    Messages : 219
    Points : 72
    Points
    72
    Par défaut

  20. #20
    Expert éminent Avatar de Mr N.
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    5 418
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 5 418
    Points : 6 449
    Points
    6 449
    Par défaut
    J'ai pas compris ce qui c'est passé ? windows a planté ???

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [XL-2007] Formulaire avec liste des feuilles permettant de naviguer dans le classeur
    Par blackstrange dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 29/06/2012, 16h54
  2. Réponses: 7
    Dernier message: 20/11/2008, 14h22
  3. Formulaire en plusieurs parties ? (avec controle des erreurs)
    Par fabseven dans le forum Ruby on Rails
    Réponses: 0
    Dernier message: 04/04/2008, 16h23
  4. Réponses: 7
    Dernier message: 14/01/2008, 12h12
  5. Formulaire avec liste basée sur une autre table
    Par sabotage dans le forum Langage SQL
    Réponses: 6
    Dernier message: 10/08/2005, 13h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo