Ciao a tutti,
premetto che di javascript sono proprio a zero.
Ho trovato una funzione su internet in java appunto cercando di adattarla al mio form ma a qiuanto pare non funziona.
Chi di voi è così gentile da dirmi come fare? Di seguito posto sia il form in HTML sia lo script in java.
Grazie infinite.
HTML
Codice HTML:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="Azienda agricola Tappero Bertot">
<meta name="robots" content="index, follow">
<meta http-equiv="content-language" content="it">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="viewport" content="width=device-width">
<title>Documento senza titolo</title>
<link href="../css/modulomail.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/validator.js"></script>
</head>
<body>
<form name="contact_form" method="post" action="invio.php">
<table width="300" border="0" align="center" cellpadding="10" cellspacing="3" id="table_cliente">
<tr>
<td align="center">Informazioni del cliente</td>
</tr>
</table>
<table width="360" height="205"border="0" align="center" cellpadding="0" cellspacing="0" id="table_cont">
<tr>
<td width="30" height="200" align="center"><table width="100%" border="0" cellpadding="8" cellspacing="1" id="table1">
<tr>
<td width="30" valign="middle">Nome</td>
<td width="70" valign="middle"><input name="fname" type="text" value="" placeholder="Inserisci il tuo nome"></td>
</tr>
<tr>
<td valign="middle">Mail</td>
<td valign="middle"><input name="text" type="mail" value="" placeholder="Inserisci la tua mail"></td>
</tr
><tr>
<td valign="middle">Telefono</td>
<td valign="middle"><input name="phone" type="text" value="" size="10" maxlength="10"placeholder="Telefono"></td>
</tr>
<tr>
<td valign="middle">Oggetto</td>
<td valign="middle"><input name="subject" type="text" placeholder="Oggetto (es.Ordine)"></td>
</tr>
</table></td>
<td width="65%" height="205"align="center"><table width="100%" border="0" cellpadding="8" cellspacing="3" id="table2">
<tr>
<td valign="middle">Richiesto</td>
</tr>
<tr>
<td valign="middle">Richiesto</td>
</tr>
<tr>
<td valign="middle">Richiesto</td>
</tr>
<tr>
<td valign="middle"> </td>
</tr>
</table></td>
</tr>
</table>
<table width="300" border="0" align="center" cellpadding="10" cellspacing="3" id="table_mess">
<tr>
<td align="center">Il tuo messaggio</td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="10" cellspacing="3" id="table_messaggio">
<tr>
<td width="40" align="center"></td>
</tr>
<tr>
<td align="center">Messaggio</td>
<td align="center"><textarea name="message" cols="35" rows="5" placeholder="Scrivi qui il tuo messaggio"></textarea></td>
<td align="center">Richiesto</td>
</tr>
<tr>
<td align="right"> </td>
<td align="center"><input type="reset" name="reset" value="Reset"/> <input type="submit" name="Submit" value="Invia" onclick="return thisform(this.contact_form)"></td>
</tr>
</table>
</form>
</body>
</html>
JAVAscript
Codice:
// JavaScript Document
function thisform(contact_form) {
if(contact_form.fname.value == "") {
alert('Riempire il campo: Nome');
return false;
}
}