







|
|
|
 |
| > Problème dans une fonction |
[ Posté par wallys ] [ Détails ] [ Contact ] [ Citer ]
[ Posté le 12-09-2001 à 15:45 | 13 messages ]
  J'ai un problème dans ma page PHP, rien ne ce passe, lorsque je démarre ma page voire code dessous, car lorsque je clique sur le bouton, normalement, ça devrait vérifier tout les champs, mais ça ne marche pas.
Juste un petit truc, ma page contient un include d'1 fichier JS. J'ai aussi essayé de mettre la fonction de verif dedans, mais rien ne marche (rien ne se passe)
Voici le code de ma page :
<html>
<head>
<SCRIPT language="javascript" src="fonctions.js"></SCRIPT>
<script language="javascript">
function verifastuce()
{
alert ("khjkjhkj");
var verif = 0;
var alert = "";
var mail = document.astuce.email.value;
var auteur = document.astuce.auteur.value;
var titre = document.astuce.titre.value;
var astuce = document.astuce.astuce.value;
if (document.astuce.astuce.value == "Astuce...")
{
alert = alert + "Merci de remplir le champ astuce !!! \n\n";
window.document.astuce.astuce.focus()
window.document.astuce.astuce.select()
}
else
{
verif = verif + 1;
}
if (document.astuce.titre.value == "")
{
alert = alert + "Merci de remplir le champ titre !!! \n\n";
window.document.astuce.titre.focus()
window.document.astuce.titre.select()
}
else
{
verif = verif + 1;
}
if (document.astuce.email.indexOf("@")==-1 || document.astuce.email.value.indexOf("@")==0 || document.astuce.email.value.indexOf(".")==-1 || document.astuce.email.value.indexOf(".")==0 || document.astuce.email.value.length<=5 )
{
alert = alert + "L\'adresse e-mail : \""+mail+"\" est INVALIDE \n\n";
window.document.astuce.email.focus()
window.document.astuce.email.select()
}
else
{
verif = verif + 1;
}
if (document.astuce.auteur.value == "")
{
alert = alert + "Merci de remplir le champ nom !!! \n\n";
window.document.astuce.auteur.focus()
window.document.astuce.auteur.select()
}
else
{
verif = verif + 1;
}
if (verif == "4")
{
document.verif.submit()
}
else
{
alert (alert);
}
}
</script>
</head>
<body>
<?php
print ("<form name='astuce' method='post' action='ajout_astuce.php3'>
<table border='1' align='center' bordercolor='#000000' cellspacing='1' cellpadding='2'>
<tr>
<td bgcolor='#0000aa' class='textec' colspan='2'>
<big>Ajouter une astuce</big>
</td>
</tr>
<tr>
<td color='#bbbbff' class='texte'>
</select><br>
Nom : <input type='text' name='auteur' value=''><br>
E-mail : <input type='text' name='email' value=''><br>
Titre : <input type='text' name='titre' value=''><br>
<br>
<textarea name='astuce' cols='40' rows='10'>
Astuce...
</textarea>
<br>
<input type='button' name='soumettre' value=\"Ajouter l'astuce\" onClick='verifastuce()'>
</td>
</tr>
</table>
</form>");
?>
MERCI DE M'ECLAIRCIR
 
|
|
Services email :
  Vous devez vous identifier pour profiter des services par email du forum.
|

|