Bonjour,
J'essaye de faire un check de mes champs issus d'un formulaire mais ca ne fonctionne pas
Javascript
et le HTML
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 function couleur(obj) { obj.style.backgroundColor = "#FFFFFF"; } function check(nombre) { var msg = ""; if(nombre.value == ""){ if (document.formulaire.nom_emprunteur.value == "") { msg += "Veuillez saisir le nom\n"; document.formulaire.nom_emprunteur.style.backgroundColor = "#FFCC66"; } } for(var i =1; i<=nombre; i++){ if (document.formulaire.['nom_associe'+i].value == "") { msg += "Veuillez saisir le nom\n"; document.formulaire.['nom_associe'+i].style.backgroundColor = "#FFCC66"; } if (document.formulaire.['prenom_associe'+i].value == "") { msg += "Veuillez saisir le prenom\n"; document.formulaire.['prenom_associe'+i].style.backgroundColor = "#FFCC66"; } if (document.formulaire.['datenaissance_associe'+i].value == "") { msg += "Veuillez saisir la date de naissance\n"; document.formulaire.['datenaissance_associe'+i].style.backgroundColor = "#FFCC66"; } } if (msg == "") return(true); else { alert(msg); return(false); } }
Merci du coup de main
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 <form action="../FRONTCONTROLER/FrontControler.php" method="GET" enctype="application/x-www-form-urlencoded" name="formulaire" onSubmit="return check(<?php echo $nb_associe; ?>);"> <input type="text" name="nom_emprunteur" value="<?php echo $nom_emprunteur;?>" onKeyUp="javascript:couleur(this);" /> </div></td></tr> </tr><tr><td height="33">Nombre d'associé </td> <td><input name="nbassocie" type="text" size="5" maxlength="5" value="<?php echo $nb_associe;?>"/></td></tr> <tr><td height="25" colspan="4" align="left"><br/> <table width="786" border="0" cellpadding="0" cellspacing="0"> <tr><td colspan="6" align="center"><strong>ASSOCIÉS</strong></td> </tr><tr><td width="169"><div align="center"><strong>Nom *</strong></div></td> <td width="169"><div align="center"><strong>Prénom *</strong></div></td> <td width="229"><div align="center"><strong>Date de Naissance *</strong></div></td> <td width="165"><div align="center"><strong>Numéro CP </strong></div></td> <td colspan="2"> <div align="center"><strong>test</strong></div></td></tr> <?php for($i = 1; $i<=$nb_associe; $i++){ echo "<tr><td><input type=text name=nom_associe".$i." ";?> onKeyUp="javascript:couleur(this);" <?php echo"></td><td><input type=text name=prenom_associe".$i."";?> onKeyUp="javascript:couleur(this);" <?php echo"></td><td align=center><input id=datenaissance_associe type=text name=datenaissance_associe".$i." size=10";?> onKeyUp="javascript:couleur(this);" <?php echo" /> <script language=JavaScript> new tcal ({ // form name 'formname': 'formulaire', // input name 'controlname': 'datenaissance_associe$i' }); </script></td> <td><input type=text name=numcp_associe".$i." size=9 maxlength=9></td> <td width=62><input type=radio name=radiobutton_associe".$i." value=oui>oui</td> <td width=54><input type=radio name=radiobutton_associe".$i." value=non>non</td> </tr>"; } ?> </table></form>
Partager