Vérification de 2 champs avec une fonction

Résolu/Fermé
genidou Messages postés 10 Date d'inscription lundi 17 mars 2008 Statut Membre Dernière intervention 9 décembre 2008 - 7 déc. 2008 à 05:45
genidou Messages postés 10 Date d'inscription lundi 17 mars 2008 Statut Membre Dernière intervention 9 décembre 2008 - 7 déc. 2008 à 06:22
Bonjour,
JAVASCRIPT
Quand le client pèse sur submit, ma fonction doit vérifier si l'un des 2 champs est vide.. j'ai créé une fonction:

function verifchamp(champ) {
if(champ =="") {
alert("Un champ est vide");
return false;

}
return true;
}

ensuite il y a le formulaire :

<form name="form1" onSubmit="verifchamp(document.form1.nom.value)"> JE REUSSI A VÉRIFIER LE CHAMP NOM, MAIS JE NE SAIS PAS COMMENT VÉRIFIER LE CHAMP FAB... J'AI AUCUNE IDÉE DE COMMENT FAIRE ... SI JE RÉÉCRIS ONSUBMIT.... CA NE FONCTIONNE PAS
<table>
<tr>
<td>nom:</td>
<td><input type="text" name="nom" /><td>
</tr>
<tr>
<td>fabricant :</td>
<td><input type="text" name="fab" /><td>
</tr>
</table>

AIDEZ MOI SVPP...

merci d'avance
A voir également:

1 réponse

genidou Messages postés 10 Date d'inscription lundi 17 mars 2008 Statut Membre Dernière intervention 9 décembre 2008
7 déc. 2008 à 06:22
il fallais simplement les séparé par &&

<form name="form1" onSubmit="verifchamp(document.form1.nom.value) && verifchamp(document.form1.fab.value)">
0