Bonjour!
j'ai un formulaire que je veux vérifier avec javascript mais je constate qu'aucune vérification n'est faite en l'envoi du formulaire.
aidez moi à retrouver mes erreurs afin de rendre mon code fonctionnel . merci pour votre aide.
voicimon code :

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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
 
<script type="text/javascript">
 
function surligne(champ, erreur)
{
   if(erreur)
      champ.style.backgroundColor = "#fba";
   else
      champ.style.backgroundColor = "";
}
 
function verifMois(champ)
{
 
   if(champ.value="")
 
   {
   surligne(champ, true);
      return false;
   }
   else
   {
      surligne(champ, false);
      return true;
   }
  }
 
 function verifSem(champ)
{
if(champ.value="")
   {
   surligne(champ, true);
      return false;
   }
   else
   {
      surligne(champ, false);
      return true;
   }
  }
 
  function verifAnnee(champ)
 {
   if(champ.value="")
 {
   surligne(champ, true);
      return false;
   }
   else
   {
      surligne(champ, false);
      return true;
   }
  }
 
  function verifNbre(champ)
  {
for(i=0;i<champ.value.length;++i){
   if(champ.value.charAt(i) < "0"
   || champ.value.charAt(i) > "9"){
 
       surligne(champ, true);
       return false;
    }
    }
 
  }
  function veirfTotal(champ){
for(i=0;i<champ.value.length;++i){
   if(champ.value.charAt(i) < "0"
   || champ.value.charAt(i) > "9"){
 
       surligne(champ, true);
       return false;
    }
    }
  }
 
  funtion verifDu(champ){
for(i=0;i<champ.value.length;++i){
   if(champ.value.charAt(i) < "0"
   || champ.value.charAt(i) > "9"){
 
       surligne(champ, true);
       return false;
    }
    }
  }
 
  function verifLieu(champ)
   {
   var regex = ^[a-zA-Z0-9_-]{6,20}$;
   if(!regex.test(champ.value))
   {
      surligne(champ, true);
      return false;
   }
   else
   {
      surligne(champ, false);
      return true;
   }
}
 
  function verifUser(champ) {
var regex = ^[a-zA-Z0-9_-]{6,20}$;
 if(!regex.test(champ.value))
  {
   surligne(champ, true);
      return false;
   }
   else
   {
      surligne(champ, false);
      return true;
   }
  }
 
  function verifForm(dec)
{
   var moisOk = verifMois(dec.mois);
   var semestreOk = verifSem(dec.sem);
   var anneeOk = verifAnnee(dec. annee);
   var nbreOk = verifNbre(dec.salarie);
   var totalOk = verifTotal(dec.imposable);
   var duOk = verifDu(dec.du);
   var lieuOk = verifLieu(dec.lieu);
   var userOk = verifUser(dec.usersaisie);
 
   if((moisOk||semestreOk) && anneeOk&&nbreOk&&totalOk&&duOk&&lieuOk&&userOk)
      return true;
   else
   {
      alert("Veuillez remplir correctement tous les champs");
      return false;
   }
}
 
</script>
 
</head>
 
<body bgcolor="#66FF99">
<p align="center"><strong> </strong></p>
<ul>
  <li>
    <div align="left"><strong align="left"></strong></div>
  </li>
</ul>
<form id="form" name="dec" method="post" action="insertion.php" onsubmit="return verifForm(this)">
  <strong>I. PERIODE</strong> Mois
  <select name="mois" onblur="verifMois(this)">
    <option selected="selected"> </option>
    <option>01</option>
    <option>02</option>
    <option>03</option>
    <option>04</option>
    <option>05</option>
    <option>06</option>
    <option>07</option>
    <option>08</option>
    <option>09</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
  </select>
Semestre
<select name="sem" onblur="verifSem(this)">
  <option selected="selected"> </option>
  <option>01</option>
  <option>02</option>
</select> 
Année
<select name="annee" onblur="verifAnnee(this)">
  <option selected="selected"> </option>
  <option>2009</option>
  <option>2010</option>
  <option>2011</option>
  <option>2012</option>
  <option>2013</option>
  <option>2014</option>
  <option>2015</option>
  <option>2014</option>
  <option>2015</option>
  <option>2016</option>
  <option>2017</option>
  <option>2018</option>
  <option>2019</option>
  <option>2020</option>
</select>
 
  <table width="653" border="0">
    <tr>
      <td width="221"><div align="center"><strong>Nombre </strong></div></td>
      <td width="220"><div align="center"><strong>Total </strong></div></td>
      <td width="190"><div align="center"><strong>Total du d&ucirc; </strong></div></td>
    </tr>
    <tr>
      <td><label>
        <input size="30" type="text" name="salarie"  onblur="verifNbre(this)"/>
      </label></td>
      <td><label>
        <input size="30" type="text" name="imposable"  onblur="verifTotal(this)"/>
      </label></td>
      <td><label>
        <input size="30" type="text" name="du"  onblur="verifDu(this)"/>
      </label></td>
    </tr>
  </table>
  <p>
    <label></label>
    A
  <label>
  <input
  size="30" type="text" name="lieu" onblur="verifLieu(this)" />
  </label>
    , le
  <label>
  <input name="datesaisie" type="text" />
  </label>
  </p>
  <p>
    <label>Nom et Pr&eacute;nom 
      <input size="50" type="text" name="usersaisie"  onblur="verifUser(this)"/>
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="Enregistrer" />
    </label>
    <input type="reset" name="Submit2" value="R&eacute;initialiser" />
  </p>
  <p>&nbsp;</p>
</form>
<p>&nbsp;</p>
</body>
</html>