Validation formulaire html.pdf


Aperçu du fichier PDF validation-formulaire-html.pdf

Page 1 2 3 4 5 6 7 8 9




Aperçu texte


Validation d’un formulaire HTML

Abdallah EL Asmar

1. Utilisation de JavaScript pour la validation
Code HTML
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="language" content="fr">
<title>Validation d'un formulaire</title>
<script src = "validerForm.js"></script>
</head>
<body style="font-size:20px" onload= "document.getElementById('champ1').focus(); afficherDate()">
<h2>Welcome</h2>
<form onsubmit="return valider()" method ="POST">
<fieldset style="background: #DFF2FF ;">
<legend style="background: #77B5FE ;"> <B>Date courante</B></LEGEND>
<input type="text" name="datecourante" id= "champ0" size="30" readonly>
</fieldset>
<fieldset style="background: #DFF2FF ;">
<legend style="background: #77B5FE ;"> <B>Formulaire d'inscription</B></LEGEND>
<table>
<tr> <td> Numéro</td>
<td><input type="text" name="numero" id= "champ1" onblur = "validNo()" size="20">
</td></tr>
<tr> <td> Nom</td>
<td><input type ="text" name = "nom" id= "champ2" onblur = "validNom()" size= "20">
</td></tr>
<tr> <td> Prénom</td>
<td><input type="text" name="prenom" id= "champ3" onblur="validPrenom()" size="20" >
</td></tr>
<tr> <td> Date de naissance</td>
<td><input type="text" name="naissance" id= "champ4" onblur ="validNaissance()" >
</td></tr>
<tr> <td> Téléphone</td>
<td><input type="text" name="tel" id= "champ5" onblur="validTel()"size="20"></td></tr>
<tr> <td> Ville</td>
<td><input type="text" name="ville" id= "champ6" value = "Ville"
onfocus="this.value=''" onblur="validVille()" size="20"></td></tr>
<tr> <td><input type="submit" value="Envoyer"></td><td></td></tr>
</table>
</fieldset>
</form>
</body>
</html>

www.facebook.com/a.asmar.isae

Page 2