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
| <?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%
String nom = (String)session.getAttribute("nom");
String age = (String)session.getAttribute("age");
%>
<!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>
<title>Formulaire - Personne</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script language="javascript"> <!-- type="text/javascript ??" -->
// ------------------------------
function effacer()
{
// Effacement des champs de saisie :
with(document.frmPersonne)
{
txtNom.value = "";
txtAge.value = "";
}
}
function envoyer()
{
// Vérifcation validité des champs de saisie avant l'envoi des paramètres
with(document.frmPersonne)
{
// Le nom ne doit pas être vide
champs = /^\s*$/.exec(txtNom.value);
if(champs != null) // alors le nom est vide
{
alert("Vous devez indiquer un nom");
txtNom.value = "";
txtNom.focus(); // (problème1)positionnement du curseur clignotant ds le champ
// retour à l'ineterface visuel
return;
}
// L'âge doit être un enteir positif
champs = /^\s*\d+\s*$/.exec(txtAge.value);
if(champs == null)
{
alert("Âge incorrect");
txtAge.focus(); // (problème2)
// retour à l'ineterface visuel
return;
}
// Les paramètres sont corrects on les envoie au serveur :
submit(); // (problème3)
}
}
</script>
</head>
<body>
<center>
<h2>Formulaire - Personne</h2>
<hr />
<form name="frmPersonne" method="post">
<table>
<tr>
<td>Nom</td>
<td> <input name="txtNom" value="<%= nom %>" type="text" size="20"/> </td>
</tr>
<tr>
<td>Age</td>
<td> <input name="txtAge" value="<%= age %>" type="text" size="3"/> </td>
</tr>
</table>
<table>
<tr>
<td> <input type="submit" value="Submit" /> </td>
<td> <input type="button" value="[Envoyer]" onclick="envoyer()"/> </td>
<td> <input type="reset" value="Rétablir"/> </td>
<td> <input type="button" value="[Effacer]" onclick="effacer()"/> </td>
</tr>
</table>
<input type="hidden" name="action" value="validationFormulaire" />
</form>
</center>
</body>
</html> |
Partager