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

JavaScript Discussion :

controle de champs de formulaire JS


Sujet :

JavaScript

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut controle de champs de formulaire JS
    bonjour et bonne rentrée
    j'ai un formulaire html et un fichier javascript qui controle les données saisie sur l'evènément onclick avec la fonction alert().


    celui la marche
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    function verif() 
    { 
     
    	var i=0;
    	while(i<3){
    	alert(i);
    	i++;
    	return i;
    	}
     
    }

    celui ne marche pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    function verif() 
    { 
     
     
    if(document.monForm.rens1.value == "")
    	{
    		alert ('Veuillez entrer votre prénom');
    		document.formulaire.prenom.focus();
    		return false;
    	}
    }
    je trouve pas l'erreur

  2. #2
    Expert confirmé
    Avatar de emmanuel.remy
    Inscrit en
    Novembre 2005
    Messages
    2 855
    Détails du profil
    Informations personnelles :
    Âge : 56

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 855
    Points : 4 045
    Points
    4 045
    Par défaut
    Salut,

    Tu peux poster ton formulaire stp ?

    ERE

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut code formulaire
    Code HTML : 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
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Comptabilite fiche tiers</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
     <script  type="text/javascript" src="Script.js"></script>
     
     
     
    </head>
    <body>
    <div id="en_tete">
       <!-- Ici on mettra la bannire -->
       	<h1><a href="#">FICHE</a></h1>
     
    </div>
     
     
    <div id="menu">
    			<ul>
    				<li class="current_page_item"><a href="#">Accueil</a></li>
    				<!--<li><a href="#"></a></li>-->
    				<li><a href="doc/rr.pdf">Modele Fiche </a></li>	
     
    		<!--<form method="post" action="">
     
    				<input type="text" name="s" id="recherche-text" size="15" />
    				<input type="submit" id="recherche-submit" value="Rechercher" />
     
    			</form>-->
    			<li class="current_page_item"><a href="fichetiersResultat.php">Listes Des fiches </a></li>
     
     
    			</ul>
    		<!-- Ici on mettra le menu -->
    </div>
     
    <div id="corps">
       <!-- Ici on mettra le contenu principal de la page (tout le texte quoi) -->
    <!-- bbb  01/07/2009------------------------------------------------------------------------------>
    <form id="monForm" action="" method="post" >
     
    <fieldset>
    <legend>Reseignement 1</legend>
     
    <label for="rens1">rens1: </label>
    <input type="text" id="rens1" name="rens1" /><br/>
    <label for="rens2">rens2 : </label>
    <input type="text" id="rens2" name="rens2"/><br/>
     
    <!--<label for="Mission">Mission : </label>
    <input type="text" id="Mission" name="Mission" /><br/>-->
     
    <label for="rens3">rens3 : </label>
    <input type="text" id="rens3" name="Telephone"/><br/>
    <label for="rens4">rens4 : </label>
    <input type="text" id="rens4" name="rens4"/>
     
     
    </fieldset><br/><br/>
    <!-----------------------------
    ------------------------------------>
    <fieldset>
    <legend>TYPE DE DEMANDE</legend>
    <label>Type de Demande:</label>
    <label><SELECT name="NomServiceEmetteur">
    		<OPTION VALUE="Creation">Creation </OPTION>
    		<OPTION VALUE="Modification">Modification</OPTION>
    		<OPTION VALUE="Suppression">Suppression</OPTION>
    	</SELECT></label>
    <br/><br/>
    <label>Type de tiers :</label>
    <label><SELECT name="NomS">
    		<OPTION VALUE="F">Fournisseur </OPTION>
    		<OPTION VALUE="Cl">Client(Debiteur)</OPTION>
    		<OPTION VALUE="L">Les Deux</OPTION>
    	</SELECT></label>
    <br/><br/>
    <label for="Objet">Objet modification:</label>
    <INPUT type=text name="objetmodif">
    <br/>
    <br/>
    <label for="Objet">Date Demande modification/creation:</label>
    <INPUT type=text name="Date">
    <br/><br/>
    <label for="Num">Num tier:</label>
    <INPUT type=text name="numtier"> 
    </fieldset><br/><br/>
     
    <!------------------------------bbb---------------------------------->
     
    <fieldset>
    <input type="Submit" name="Enregistrer"  value="Enregistrer" onClick="verif()"/>
    <input type="reset" name="Annuler" value="Annuler" />
    <input type="reset" name="Quitter" value="Quitter"/>
    </fieldset>
    </form><br/><br/>
     <!------------------------------------------------   01/07/2009------------------------------------------------------------------------------>  
    </div>
     <div id="pied_de_page">
     <div id="Bande">
     
    </div>
     
       <!-- Enfin, on mettra en bas de la page le nom de l'auteur, un copyright... -->
       <p>Copyright (c) 2009  All rights reserved. </p>
    </div>
     
    </body>
    </html>

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut Code css
    Code CSS : 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
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    body {
    	margin-top: 20px;
    	padding: 0;
    	background: #A8A604;
    	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    	font-size: 13px;
    	color: #FFFFFF;
    }
     
    h1, h2, h3 {
    	margin: 0;
    	font-family: Georgia, "Times New Roman", Times, serif;
    	font-weight: normal;
    	color: #649632;
    }
     
    h1 { font-size: 44px; }
     
    h2 { font-size: 26px; }
     
    h3 { }
     
    p, ul, ol {
    	margin-top: 0;
    	line-height: 240%;
    	text-align: justify;
    	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    	font-size: 11px;
    }
     
    ul, ol { }
     
    blockquote { }
     
    a { color: #000000; }
     
    a:hover { text-decoration: none; }
     
    a img {
    	border: none;
    }
     
    img.left {
    	float: left;
    	margin: 7px 30px 0 0;
    }
     
    img.right {
    	float: right;
    	margin: 7px 0 0 30px;
    }
     
    hr { display: none; }
     
    .list1 {
    }
     
    .list1 li {
    	float: left;
    	line-height: normal;
    }
     
    .list1 li img {
    	margin: 0 30px 30px 0;
    }
     
    .list1 li.alt img {
    	margin-right: 0;
    }
     
    #wrapper {
    }
     
    /* Header */
     
    #header-wrapper {
    	width: 900px;
    	margin: 0 auto;
    }
     
    #header {
    	width: 900px;
    	height: 70px;
    	margin: 0 auto;
    	background: url(images/img02.jpg) no-repeat left top;
    }
     
    /* Menu */
     
    #menu {
    	float: left;
    	width: 540px;
    	height: 50px;
    }
     
    #menu ul {
    	margin: 0;
    	padding: 13px 0 0 10px;
    	list-style: none;
    	line-height: normal;
    }
     
    #menu li {
    	display: block;
    	float: left;
    }
     
    #menu a {
    	display: block;
    	float: left;
    	margin-right: 17px;
    	padding: 5px 12px;
    	text-decoration: none;
    	font: 14px Georgia, "Times New Roman", Times, serif;
    	color: #FFFFFF;
    }
     
    #menu a:hover { text-decoration: underline; }
     
    #menu .current_page_item a {
    	color: #FFFFFF;
    }
     
    /* Search */
     
    #search {
    	float: right;
    	width: 305px;
    	height: 76px;
    }
     
    #search form {
    	float: right;
    	margin: 0;
    	padding: 15px 20px 0 0;
    }
     
    #search fieldset {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
     
    #search input {
    	float: left;
    	font: 12px Georgia, "Times New Roman", Times, serif;
    	border: none;
    }
     
    #search-text {
    	width: 135px;
    	height: 18px;
    	padding: 3px 0 0 5px;
    	background: #ECF9E4;
    	color: #658453;
    }
     
    #search-submit {
    	height: 21px;
    	margin-left: 12px;
    	color: #39561D;
    }
     
    /* Page */
     
    #page {
    	width: 900px;
    	margin: 0 auto;
    }
     
    /** LOGO */
     
    #logo {
    	height: 260px;
    	background: url(images/img01.jpg) no-repeat left top;
    }
    #Bande {
    	height: 26px;
     
    	background: url(images/img10.jpg) no-repeat left top;
    }
     
    #logo h1, #logo p {
    	float: left;
    	margin: 0;
    	padding: 0 0 0 20px;
    	line-height: normal;
    }
     
    #logo h1 { padding-top: 140px; }
     
    #logo h1 a {
    	text-decoration: none;
    	text-transform: uppercase;
    	color: #FFFFFF;
    }
     
    #logo h1 a:hover { text-decoration: underline; }
     
    #logo p {
    	padding: 165px 0 0 15px;
    	font: italic 13px Georgia, "Times New Roman", Times, serif;
    	color: #B6ACA2;
    }
     
    #logo p a {
    	text-decoration: none;
    	color: #B6ACA2;
    }
     
    #logo p a:hover { text-decoration: underline; }
     
    /* Content */
     
    #content {
    	float: left;
    	width: 620px;
    }
     
    /* Post */
     
    .post {
    	margin-bottom: 25px;
    }
     
    .post .title {
    	height: 55px;
    	margin-bottom: 3px;
    	padding: 19px 0px 2px 20px;
    	background: url(images/img05.jpg) no-repeat left top;
    	color: #FFFFFF;
    }
     
    .post .date {
    	float: right;
    	margin-top: -60px;
    	padding-right: 40px;
    	font-weight: bold;
    	font-size: 14px;
    	color: #B6ACA2;
    }
     
    .post .meta {
    	margin: -40px  0 3px 25px;
    	padding: 2px 30px 2px 0px;
    	font-family: Arial, Helvetica, sans-serif;
    	font-weight: normal;
    	font-size: 10px;
    	color: #B6ACA2;
    }
     
    .post .meta a { color: #B6ACA2; }
     
    .post .entry {
    	padding: 25px 20px;
    }
     
    .post .links {
    	margin: 0 250px 0 0;
    	padding: 0 0 0 0px;
    }
     
    .post .links .comments {
    }
     
    .post .links .permalink {
    	padding-left: 17px;
    }
     
    /* Sidebar */
     
    #sidebar {
    	float: right;
    	width: 250px;
    }
     
    #sidebar ul {
    	margin: 0;
    	padding: 0;
    	list-style: none;
    	line-height: normal;
    }
     
    #sidebar li {
    	margin-bottom: 30px;
    	padding: 0 0 20px 0px;
    	background: url(images/img04.jpg) no-repeat left bottom;
    }
     
    #sidebar li ul {
    	line-height: 200%;
    	padding-bottom: 20px;
    }
     
    #sidebar li li {
    	margin: 0;
    	padding: 0 20px;
    	background: none;
    }
     
    #sidebar h2 {
    	height: 33px;
    	margin: 0 0 20px 0px;
    	padding: 15px 0 2px 20px;
    	background: url(images/img03.jpg) no-repeat left top;
    	font-size: 18px;
    	color: #FFFFFF;
    }
     
     
    #sidebar p {
    	padding: 0px 15px;
    	line-height: 200%;
    }
     
    #sidebar a {
    	color: #FFFFFF;
    }
     
    /* Calendar */
     
    #calendar {
    }
     
    #calendar caption {
    	padding-bottom: 5px;
    	font-weight: bold;
    }
     
    #calendar table {
    	width: 90%;
    	border-collapse: collapse;
    }
     
    #calendar thead th {
    	padding: 5px 0;
    	text-align: center;
    }
     
    #calendar tbody td {
    	padding: 5px 0;
    	text-align: center;
    }
     
    #calendar tfoot td {
    	padding: 5px;
    }
     
    #calendar tfoot #next {
    	text-align: right;
    }
     
    #calendar #today {
    	background: #000000;
    }
     
    /* Footer */
     
    #footer {
    	width: 900px;
    	height: 60px;
    	margin: 0 auto;
    	padding: 0;
    	background: url(images/img06.jpg) no-repeat left top;
    }
     
    #footer p {
    	margin: 0;
    	padding: 20px 0;
    	text-align: center;
    	line-height: normal;
    	color: #B5ADA5;
    }
     
    #footer a {
    	color: #B5ADA5;
    }
    /************************************************************************/
    #monForm
    {
    /*width: 60%;*/
    }
    #monForm p
    {
    /*margin: 2px 0;*/
    }
    /* fieldset , legend */
    #monForm fieldset
    {
    /*margin-bottom: 10px;*/
    border:  #ccc 2px solid;
    }
    #monForm fieldset:hover
    {
    background-color: #FFF;
    }
    #monForm fieldset legend
    {
    padding: 0 10px;
    border-left: #CCC 1px solid;
    border-right: #CCC 1px solid;
    font-size: 1.2em;
    color: blue;
    }
     
    /* Label */
    #monForm label
    {
    /*background-color: #FFCC66;
    display: block;*/
    width: 39%;
    float: left;
    padding-right: 1%;
    text-align: right;
    letter-spacing: 1px;
    }
    #monForm label:hover
    {
    font-weight: bold;
    }
    #monForm .form_label_nostyle
    {
    background: none;
    }
    /* Input */
    #monForm input, #monForm select
    {
    margin-left: 1%;
    width: 58%;
    border: #CCC 1px solid;
    }
    #monForm input:hover, #monForm select:hover, #monForm input:focus, #monForm select:focus
    {
    border: #999 1px solid;
    background-color: #DDEEFF;
    }
    #monForm .form_input_day_month
    {
    width: 3%;
    }
    /* button submit */
    #monForm input[type="submit"]
    {
    border: #DDEEFF 1px solid;
    width: 27%;
    }
    #monForm input[type="submit"]:hover
    {
    background-color: #66CC33;
    cursor: pointer;
    }
    #monForm input[type="reset"]
    {
    border: #DDEEFF 1px solid;
    width: 27%;
    }
    #monForm input[type="reset"]:hover
    {
    background-color: #E6484D;
    cursor: pointer;
    }
    /****

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut

    if(document.formulaire.prenom.value == "")
    Ton formulaire n'a pas d'attribut name="formulaire" ni d'un element avec le name="prenom".

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut JS PHp HtML CSS
    personne pour me donner des idées constructives?
    merci

  7. #7
    Expert confirmé
    Avatar de emmanuel.remy
    Inscrit en
    Novembre 2005
    Messages
    2 855
    Détails du profil
    Informations personnelles :
    Âge : 56

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 855
    Points : 4 045
    Points
    4 045
    Par défaut
    Salut,

    Citation Envoyé par afroweb Voir le message
    personne pour me donner des idées constructives?
    merci
    Ne néglige surtout pas ce que te conseille andry.aime.

    Sinon pour ta question il te manque name=... dans ta balise forme:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <form id="monForm" name="monForm" action="" method="post" >

    ERE

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut merci
    je vais essayer de voir ce que ca donne

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    76
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 76
    Points : 34
    Points
    34
    Par défaut merci a vous deux
    effectivement il manquait le name
    par contre vous savez pourqoui mon css ne s'affiche pas pareil selon fire fox ou internet exploreur

  10. #10
    Expert confirmé
    Avatar de emmanuel.remy
    Inscrit en
    Novembre 2005
    Messages
    2 855
    Détails du profil
    Informations personnelles :
    Âge : 56

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 855
    Points : 4 045
    Points
    4 045
    Par défaut
    Citation Envoyé par afroweb Voir le message
    effectivement il manquait le name
    par contre vous savez pourqoui mon css ne s'affiche pas pareil selon fire fox ou internet exploreur
    Les problèmes peuvent être multiples. Par exemple IE ne supportera pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    input[type="submit"]:hover
    . Poste un message dans le forum CSS tu auras des avis plus complets.

    Bon dev,

    ERE

Discussions similaires

  1. Controle des champs de formulaire
    Par okoweb dans le forum jQuery
    Réponses: 2
    Dernier message: 14/12/2011, 08h04
  2. controle des champs dans formulaire
    Par nima5 dans le forum IHM
    Réponses: 7
    Dernier message: 31/12/2007, 13h10
  3. controler les champs d'un formulaire
    Par ideal23 dans le forum Dreamweaver
    Réponses: 1
    Dernier message: 18/12/2007, 18h48
  4. Réponses: 1
    Dernier message: 02/07/2007, 17h58
  5. controler le champ d'un formulaire
    Par leonlegrand dans le forum Access
    Réponses: 6
    Dernier message: 17/07/2006, 11h28

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