ho fatto così ma non va:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>prova</title>
<link href="/altro/stile.css" type="text/css" rel="styleSheet">
<?
if ($PHP_SELF == "contatti.php") {
// stampo il codice che mi mette il javascript
// ti consiglio di fare un file .js esterno
echo "
<SCRIPT LANGUAGE='JavaScript'>
<!--
function clear_field(field)
{
if (field.value==field.defaultValue)
{
field.value=''
}
}
function check_field(field)
{
if (field.value=='' ||
field.value==' ')
{
field.value=field.defaultValue
}
}
function validate_form()
{
if (document.jsform.nome.value==document.jsform.nome. defaultValue ||
document.jsform.nome.value.indexOf(' ',0)==0)
{
alert('\nNessun Nome inserito.')
document.jsform.nome.select()
document.jsform.nome.focus()
return false
}
if (document.jsform.cognome.value==document.jsform.co gnome.defaultValue ||
document.jsform.cognome.value.indexOf(' ',0)==0)
{
alert('\nNessun Cognome inserito.')
document.jsform.cognome.select()
document.jsform.cognome.focus()
return false
}
if (document.jsform.mail.value==document.jsform.mail. defaultValue)
{
alert('\nNessun indirizzo E-MAIL.')
document.jsform.mail.select()
document.jsform.mail.focus()
return false
}
if (document.jsform.mail.value.indexOf('@',0)==-1 ||
document.jsform.mail.value.indexOf('.',0)==-1)
{
alert('\nE-MAIL non valida.')
document.jsform.mail.select()
document.jsform.mail.focus()
return false
}
if (document.jsform.testo.value==document.jsform.test o.defaultValue ||
document.jsform.testo.value.indexOf(' ',0)==0)
{
alert('\nNon è stato inserito nessun Testo.')
document.jsform.testo.select()
document.jsform.testo.focus()
return false
}
else
{
if(confirm('\nClicca su OK per inviare.'))
{
return true
}
else
{
return false
}
}
}
//----------------------------------------
// -->
</SCRIPT>
";
}
?>
</head>