Bonjour à tous,

J'ai un petit souci avec la soumission d'un formulaire.
le formulaire se trouve dans une page PHP et est vérifié via plusieurs fonctions JavaScript (pour tester le remplissage des champs, ...).

Mon submit n'est pas déclaré au niveau du "onsubmit" du formulaire mais plutôt via un test au niveau du "onclick" du bouton de validation. donc normalement, si la fonction de vérification renvoie FALSE, le submit ne doit pas être effectué, mais dans mon cas, la fonction me renvoie bien les message d'erreurs éventuels, mais elle effectue quand même le submit, donc on ne se retrouve plus sur la page du formulaire pour faire les modifications nécessaires.

je mets le code entier de la page en dessous, merci pour votre aide
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
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chez Francoise</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Author" content="Florent Norroy" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' language='javascript'>
 
// Cette fonction active ou désactive le champ "Numéro de TVA"
function check_client_pro()
{
  if (document.forms['CUSTOMER'].elements['type_client'].checked) 
    document.forms['CUSTOMER'].elements['TVASociete'].disabled = false;
  else	
  {
    document.forms['CUSTOMER'].elements['TVASociete'].disabled = true;	    
    document.getElementById('TVASocieteID').value = '';
  }  
}  
 
// Cette fonction bloque du départ le champ "Numéro de TVA"
function init_client()
{
   document.forms['CUSTOMER'].elements['TVASociete'].disabled = true;	
}
 
// Cette fonction force l'encodage de chiffres
function chiffres(event)
{
  //Compatibilité IE/FIREFOX
  if(!event&&window.event)
    event=window.event;
 
  //IE
  if(event.keycode < 48 || event.keycode > 57)
  {
    event.returnvalue = false;
    event.cancelbubble = true;	
  }
 
  //DOM
  if(event.which < 48 || event.which > 57)
  {
    event.preventDefault();
    event.stopPropagation();	
  }
 
}
 
// Cette fonction recopie l'adresse de livraison dans l'adresse de facturation
function adresse_livraison_facturation()
{
  if (document.forms['CUSTOMER'].elements['adresse_facturation'].checked)  	
  {
    document.getElementById('AdresseFacturationID').value = document.getElementById('AdresseLivraisonID').value;  	
    document.getElementById('CPFacturationID').value = document.getElementById('CPLivraisonID').value;  	
    document.getElementById('VilleFacturationID').value = document.getElementById('VilleLivraisonID').value;  	
    document.forms['CUSTOMER'].elements['AdresseFacturation'].disabled = true;	    
    document.forms['CUSTOMER'].elements['CPFacturation'].disabled = true;	    
    document.forms['CUSTOMER'].elements['VilleFacturation'].disabled = true;	    
  }
  else
  {		
    document.forms['CUSTOMER'].elements['AdresseFacturation'].disabled = false;	    
    document.forms['CUSTOMER'].elements['CPFacturation'].disabled = false;	    
    document.forms['CUSTOMER'].elements['VilleFacturation'].disabled = false;	    
  }
}
 
// Cette fonction effectue une dernière batterie de test avant de lancer l'enregistrement dans la DB
function champsformulaire()
{
  if (document.getElementById('EmailSocieteID').value.indexOf('@') < 0)
  {
    alert('Le format email est incorrect (nom@domaine.com)');
    return false;	
  }
  if (document.getElementById('EmailSocieteID').value.indexOf('@') > document.getElementById('EmailSocieteID').value.lastIndexOf('.'))
  {
    alert('Le format email est incorrect (nom@domaine.com)');	
    return false;
  }
  //La ligne suivante est a modifié pour valider le formulaire
  return true;
}
 
 
</script></head>
 
<body onload="init_client();">
<div id="container">
 
<div id="header">			
<h1>Chez Françoise Norroy</h1>
<p></p><div id="menu">
 
  <ul>
<li><a href="index.php"><span>Accueil</span></a></li>
<li><a href="soins.php"><span>Soins</span></a></li>
<li><a href="aquatonale.php"><span>Aquatonale</span></a></li>
<li><a href="coordonnees.php"><span>Coordonnées</span></a></li>
<li><a href="contact.php"><span>Contacts</span></a></li>
<li><a href="register.php"><span>Inscription</span></a></li>
<li><a href="login.php"><span><font color=black>Login</font></span></a></li>
 
  </ul>
 
 </div>
</div>
<div id="container2">
	<div id="content">
		<h2>S'enregistrez</h2>
			<p>
			L'enregistrement sur notre site est une étape obligatoire si vous voulez pouvoir commander des produits Aquatonale.<br>
			Il vous suffit de simplement remplir <b><u>tous</u></b> les champs du formulaire ci-dessous et de le valider.<br>
 
			Assurez-vous de renseigner une adresse email valide car vos coordonnées de connexion vous seront envoyés à cette adresse.<BR>
			<br><CENTER>	
			<FORM METHOD=POST NAME="CUSTOMER" ACTION="confirm_register.php">		
			<TABLE WIDTH=750>
			  <TR><TH ALIGN="middle">Formulaire d'enregistrement</TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Nom Société : <BR><INPUT TYPE=text NAME="NomSociete" VALUE="" SIZE=106 MAXLENGTH=100></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Nom Contact :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Prénom Contact : </div></TH></TR>
 
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE=text NAME="NomContact" VALUE="" SIZE=50 MAXLENGTH=50>&nbsp;&nbsp;<INPUT TYPE=text NAME="PrenomContact" VALUE="" SIZE=50 MAXLENGTH=50></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Nom d'utilisateur souhaité : <BR><INPUT TYPE=text NAME="NomUtilisateur" VALUE="" SIZE=50 MAXLENGTH=50></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE="checkbox" NAME="type_client" onclick="check_client_pro();"> Client Professionel</DIV></TH></TR>
			  <TR><TH COLSPAN=2>&nbsp;</TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Coordonnées de livraison : </div></TH></TR>			  
			  <TR><TH ALIGN="left"><DIV id="registertitle">Adresse : <BR><INPUT TYPE=text NAME="AdresseLivraison" ID="AdresseLivraisonID" VALUE="" SIZE=71 MAXLENGTH=100</div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Code Postal :&nbsp;&nbsp;&nbsp;&nbsp;Ville : </div></TH></TR>
 
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE=text NAME="CPLivraison" ID="CPLivraisonID" VALUE="" SIZE=10 MAXLENGTH=4 ONKEYPRESS="chiffres(event);">&nbsp;&nbsp;<INPUT TYPE=text NAME="VilleLivraison" ID="VilleLivraisonID" VALUE="" SIZE=55 MAXLENGTH=100></div></TH></TR>
			  <TR><TH ALIGN="left"></TH></TR>
			  <TR><TH COLSPAN=2>&nbsp;</TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Coordonnées de facturation : </div></TH></TR>			  
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE="checkbox" NAME="adresse_facturation" onclick="adresse_livraison_facturation();"> Identique à l'adresse de livraison</DIV></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Adresse : <BR><INPUT TYPE=text NAME="AdresseFacturation" ID="AdresseFacturationID" VALUE="" SIZE=71 MAXLENGTH=100></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Code Postal :&nbsp;&nbsp;&nbsp;&nbsp;Ville : </div></TH></TR>
 
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE=text NAME="CPFacturation" ID="CPFacturationID" VALUE="" SIZE=10 MAXLENGTH=4 ONKEYPRESS="chiffres(event);">&nbsp;&nbsp;<INPUT TYPE=text NAME="VilleFacturation" ID="VilleFacturationID" VALUE="" SIZE=55 MAXLENGTH=100></div></TH></TR>
			  <TR><TH ALIGN="left"></TH></TR>
			  <TR><TH COLSPAN=2>&nbsp;</TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Téléphone :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fax: </div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle"><INPUT TYPE=text NAME="TelSociete" VALUE="" SIZE=30 MAXLENGTH=9 ONKEYPRESS="chiffres(event);">&nbsp;&nbsp;<INPUT TYPE=text NAME="FaxSociete" VALUE="" SIZE=30 MAXLENGTH=9 ONKEYPRESS="chiffres(event);"></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">Email: <BR><INPUT TYPE=text NAME="EmailSociete" ID="EmailSocieteID" VALUE="" SIZE=66 MAXLENGTH=100></div></TH></TR>
			  <TR><TH ALIGN="left"><DIV id="registertitle">TVA : <BR><INPUT TYPE=text NAME="TVASociete" ID="TVASocieteID" VALUE="" SIZE=30 MAXLENGTH=9 ONKEYPRESS="chiffres(event);"></div></TH></TR>
 
			  <TR><TH ALIGN="middle"><INPUT TYPE="submit" NAME=Soumission VALUE="Valider" onclick="if(champsformulaire()) {this.form.submit()};"> &nbsp;&nbsp;&nbsp;- &nbsp;&nbsp;&nbsp;<INPUT TYPE="reset" NAME=Reset VALUE="Effacer"></TH></TR>
			</TABLE></CENTER>
			</FORM>			
			</p>
	</div>
</div><div id="footer">
<p><a href="#">Copyright</a> &copy; 2006 Florent Norroy</p>
 
</div>
</div>
 
</body>
</html>