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
|
<head>
<script>
function check() {
var msg = "";
if (document.formulaire.mail.value != "") {
indexAroba = document.formulaire.mail.value.indexOf('@');
indexPoint = document.formulaire.mail.value.indexOf('.');
if ((indexAroba < 0) || (indexPoint < 0)) {
document.formulaire.mail.style.backgroundColor = "#FF0000";
msg += "Le mail est incorrect\n";
}
else
document.formulaire.mail.style.backgroundColor = "#FFFFFF";
}
else {
document.formulaire.mail.style.backgroundColor = "#FF0000";
msg += "Veuillez saisir votre mail.\n";
}
if (document.formulaire.nom.value == "") {
msg += "Veuillez saisir votre nom\n";
document.formulaire.nom.style.backgroundColor = "#FF0000";
}
else
document.formulaire.nom.style.backgroundColor = "#FFFFFF";
if (document.formulaire.prenom.value == "") {
msg += "Veuillez saisir votre prenom\n";
document.formulaire.prenom.style.backgroundColor = "#FF0000";
}
else
document.formulaire.prenom.style.backgroundColor = "#FFFFFF";
if (msg == "")
return true;
else {
//alert(msg);
return(false);
}
}
</script>
</head>
<body>
<form method="POST" action="#" name="formulaire">
nom <input name="nom" type="text"/><BR/>
prenom <input name="prenom" type="text"/><BR/>
mail <input name="mail" type="text"/><BR/>
<input type="button" value="Sousmettre" onClick="if (check()) document.formulaire.submit();"/>
</form>
</body> |
Partager