Click to See Complete Forum and Search --> : email


diana
09-11-2003, 02:02 PM
HY

I have a form with 3 textboxes,then you push ENVOYER-bouton and you send a email....
I want to make the validation for the boxes...
I want ,when he don't write the name a message is comming
and the bouton ENVOYER don't work...
I hope you understand what I want!!!!

I want the people, must complete all the 3 boxes....

HOW CAN I DO iT?

<html>
<head>

<title>Aliz&eacute; Centre de diffusion Artistique Formulaire </title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function submitForm(sub) {
document.forms[sub].submit();
}

function proceedSubmission() {
return confirm("Appuyez sur OK pour envoyer ces informations");
}


// -->
<!--
function formatMessage(){
var chaineMail="mailto:lupumihai@yahoo.fr";
chaineMail=chaineMail+"?subject="+formulaire.Nom.value;
chaineMail+="&body= Nom :"+formulaire.Nom.value + " " + " tel : " + formulaire.phone.value + " "+ " date :" +formulaire.data.value;
location.href=chaineMail;
}
// -->
</SCRIPT>
<script language="javascript">

function valider(){


// validation pour le nom
var nom1=formulaire.Nom.value;
if (nom1==0){
alert("Erreur!Vous devrez ecrire votre nom");
return;
}




}



</script>

<link href="../gogo.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#666699" text="#ffffff">
<div align="center"></div>

<form name="formulaire" onSubmit="formatMessage();"><br>
<center>
<h3>&nbsp; </h3>
<table width="390" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="320"><div align="center" class="soustitre"><font size="3"><strong>FORMULAIRE
POUR VOUS INSCRIRE</strong></font></div></td>
<td width="45"><img src="emailed.gif" width="45" height="52"></td>
</tr>
</table>
</center>

<table width="395" border="0" cellspacing="5" align="center" cellpadding="5">
<tr>
<td width="151" class="texteNorm"> <div align="center" class="unnamed1">Nom</div></td>
<td width="191"> <input type="text" name="Nom" size="30"> </td>
<td width="8">&nbsp;</td>
</tr>
<tr>
<td width="151" > <div align="center" class="unnamed1">Téléphone</div></td>
<td width="191"> <input type="text" name="phone" size="30"> </td>
<tr>
<td width="151" valign="top" > <div align="center" class="unnamed1">Date
de l'événements</div></td>
<td width="191"> <input type="text" name="data" size="30"> </td>
<td width="8">&nbsp;</td>
</tr>
</table>
<p>&nbsp; </p>
<p align="center">
<input type="submit" onClick="valider();" name="Submit" value=" Envoyer" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="Submit2" value="Recommencer">
</p>
</form>

</table>


</body>
</html>




I write the function valider , but the email work!!!
I want ,that the email-bouton don't work,when the people
don't write in all the 3 boxes...

HOW CAN I DO IT?

THKS
DIANA

David Harrison
09-11-2003, 02:44 PM
Could you modify this:

diana
09-11-2003, 08:53 PM
Originally posted by lavalamp
Could you modify this:

OK!!!
yes I understand all but I have two question...
else{location.href="form_filled_in.html";return false;}

Who is form_filled_in.html?
Who is action="no_js.html" ?


I can send you my code...It's don't work!!! The validation is ok but to send email isn't ok!!!It don't send email!!!
Do you know?

<html>
<head>

<title>Aliz&eacute; Centre de diffusion Artistique Formulaire </title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function submitForm(sub) {
document.forms[sub].submit();
}

function proceedSubmission() {
return confirm("Appuyez sur OK pour envoyer ces informations");
}


function formatMessage(){
var chaineMail="mailto:lupumihai@yahoo.fr";
chaineMail=chaineMail+"?subject="+formulaire.Nom.value;
chaineMail+="&body= Nom :"+formulaire.Nom.value + " " + " tel : " + formulaire.phone.value + " "+ " date :" +formulaire.data.value;
location.href=chaineMail;
}

function valider(){


if(document.formulaire.Nom.value.length==0){alert("Vous devrez ecrire votre nom!!");return false;}
else if(document.formulaire.phone.value.length==0){alert("Vous devrez ecrire votre téléphone!!");return false;}
else if(document.formulaire.data.value.length==0){alert("Vous devrez ecrire la date de spectacle!!!");return false;}
else{location.href="formul.html";return false;}

}

//-->
</script>



<link href="../gogo.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#666699" text="#ffffff">
<div align="center"></div>

<form name="formulaire" action="no_js.html" method="get" onsubmit="return valider();formatMessage();"><br>


<center>
<h3>&nbsp; </h3>
<table width="390" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="320"><div align="center" class="soustitre"><font size="3"><strong>FORMULAIRE
POUR VOUS INSCRIRE</strong></font></div></td>
<td width="45"><img src="emailed.gif" width="45" height="52"></td>
</tr>
</table>
</center>

<table width="395" border="0" cellspacing="5" align="center" cellpadding="5">
<tr>
<td width="151" class="texteNorm"> <div align="center" class="unnamed1">Nom</div></td>
<td width="191"> <input type="text" name="Nom" size="30"> </td>
<td width="8">&nbsp;</td>
</tr>
<tr>
<td width="151" > <div align="center" class="unnamed1">Téléphone</div></td>
<td width="191"> <input type="text" name="phone" size="30"> </td>
<tr>
<td width="151" valign="top" > <div align="center" class="unnamed1">Date
de l'événements</div></td>
<td width="191"> <input type="text" name="data" size="30"> </td>
<td width="8">&nbsp;</td>
</tr>
</table>
<p>&nbsp; </p>
<p align="center">
<input type="submit" name="Submit" value=" Envoyer" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" name="Submit2" value="Recommencer">
</p>

</form>

</table>


</body>
</html>


I have 2 function on Submit...It's ok ,how I wrote!!!
Why it's don't work? What must I do?\\

THKS
DIANA

David Harrison
09-12-2003, 11:39 AM
When you have two solutions run onsubmit, the solution is simple. Make them into one function like this script does: