Bonjour, je veux tester sur la validité des champs du formulaire mais j'arrive pas a tester si numérique ca ne prend pa le test en considération :
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
<html>
  <head>
    <title>insertion </title>
	<SCRIPT language="javascript">
function verifForm() {
var email=document.insertion.email.value;
//var tel=document.insertion.tel.value;
	var exp = new RegExp('^[0-9-.]+$','g');
if (document.insertion.nom.value == "" || document.insertion.prenom.value== "")
	{
	               alert('Entrez toutes les infos.');
					return false;
	}
 
	else {
	if(((email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1))){	               
					alert("adresse email incorrecte")
					return false;
					}
	else if(!exp.test(document.insertion.tel.value)){
							alert("Le numéro de téléphone doit être numérique")
      						return false;
							}
	else{
		return true;
		}
 
	    }
}
</script>
 
    <link href="form.css" rel="stylesheet" type="text/css">
  </head>
<body>
<p>
<p>
<form name="insertion" action="insertion.php" method="POST" onSubmit='return verifForm();'>
  <table width="401" height="265" border="0" align="center" cellpadding="2" cellspacing="2" bordercolor="#96C168">
  <tr><td height="76" colspan="2" class="titre"><div align="center">Ajout Personne : </div></td>
  </tr>
    <tr align="center" bgcolor="#FFFFFF" class="ligne1">
      <td width="113" class="label"><div align="left">Nom</div></td>
      <td colspan=2><input name="nom" type="text" class="zone" size="30"></td>
    </tr>
    <tr align="center" class="ligne2">
      <td class="label"><div align="left">Pr&eacute;nom</div></td>
      <td colspan="2"><input name="prenom" type="text" class="zone" size="30"></td>
    </tr>
    <tr align="center" class="ligne1">
      <td class="label"><div align="left">Email</div></td>
      <td colspan="2"><input name="email" type="text" class="zone" size="30"></td>
    </tr>
    <tr align="center" class="ligne2">
      <td><div align="left" class="label">Adresse</div></td>
      <td colspan="2"><input name="adresse" type="text" class="zone" size="30"></td>
    </tr>
    <tr align="center" class="ligne1">
      <td class="label"><div align="left">Commentaire</div></td>
      <td colspan="2"><input name="codePostal" type="text" class="zone" size="30"></td>
    </tr>
    <tr align="center" class="ligne2">
      <td><div align="left" class="label">T&eacute;l&eacute;phone</div></td>
      <td colspan="2"><input name="telephone" type="text" class="zone" size="30"></td>
    </tr>
 
    <tr align="center">
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr align="center">
      <td>&nbsp;</td>
	  <td width="248" align="right"><input name="ok" type="submit" class="btn" value=""></td>
	  <td width="13">&nbsp;</td>
	   <td width="1">&nbsp;</td>
    </tr>
  </table>
</form></body>
</html>
veuillez m'aider