<!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" lang="en" xml:lang="en">
<head>
<script>
function richiestaValidata(nomeDelForm) {
messaggio = "";
//verifica se sono stati inseriti i dati necesari
datiCompilati = true ;
if (nomeDelForm.testo.value == "") {
datiCompilati = false ;
messaggio = messaggio + "Non e' stato compilato il campo. \n"
}
// in funzione della verifica precedente restituisce il buon esito o meno
if (datiCompilati) {
return true;
} else {
alert (messaggio);
return false;
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="#" onsubmit="return richiestaValidata(this)">
<br>
<table border="1">
<tr>
<td>Testo</td>
<td><input name="testo" id="testo" type="text" ></td>
</tr>
<tr>
<td align="left"><input type="button" name="Annulla" value="Annulla" ></td>
<td align="right"><input type="submit" name="Invia" value="Invia" ></td>
</tr>
</table>
</form>
</body>
</html>
Nessun commento:
Posta un commento