Vérification de 2 champs avec une fonction

Résolu
genidou Messages postés 10 Date d'inscription   Statut Membre Dernière intervention   -  
genidou Messages postés 10 Date d'inscription   Statut Membre Dernière intervention   -
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   Statut Membre Dernière intervention  
 
il fallais simplement les séparé par &&

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