Verifier les champs de formulaire
Résolu/Fermé
A voir également:
- Verifier les champs de formulaire
- Verifier un lien - Guide
- Formulaire de réclamation facebook - Guide
- Vérifier si mot de passe piraté - Guide
- Formulaire remboursement frais de résiliation free pdf ✓ - Forum Vos droits sur internet
- Verifier compatibilite windows 11 - Guide
4 réponses
function verifMail()
{
testm = false;
a=document.Form1.mail.value;
for (var j=0 ; j <(a.length) ; j++)
{
if (a.charAt(j)=='@')
{
if (j<(a.length-4))
{
for (var k=j ; k<(a.length-2) ; k++)
{
if (a.charAt(k)=='.')
{
testm = true;
}
}
}
}
}
return testm
}
tiens essaie ca mais je suis pas sur, je n'ai rien pour tester
{
testm = false;
a=document.Form1.mail.value;
for (var j=0 ; j <(a.length) ; j++)
{
if (a.charAt(j)=='@')
{
if (j<(a.length-4))
{
for (var k=j ; k<(a.length-2) ; k++)
{
if (a.charAt(k)=='.')
{
testm = true;
}
}
}
}
}
return testm
}
tiens essaie ca mais je suis pas sur, je n'ai rien pour tester
Mest aussi un else après ton premier if de verif_formulaire qui englobe tout le reste, histoire que si le nom n'est pas saisie, il se frappe pas la verif du mail
<SCRIPT language="JavaScript">
function verif_formulaire()
{
test=false;
if(document.Form1.nom.value == '' )
{
alert('Veuillez saisir votre nom!');
document.Form1.nom.value=" ";
document.Form1.nom.focus();
}
else
{
if(!verifMail())
{
alert('Veuillez saisir votre mail!');
document.Form1.mail.focus();
return false;
}
else
{
test=true;
}
}
if(test==true)
{
alert("form ok");
}
else
{
alert("form pas ok");
}
}
function verifMail()
{
testm = false ;
testat=false;
a=document.Form1.mail.value;
for (var j=0 ; j < (a.length) ; j++)
{
if (a.charAt(j)=='@')
{
testat=true;
}
if (testat && a.charAt(j)=='.')
{
testm=true;
}
}
return testm;
}
</script>
function verif_formulaire()
{
test=false;
if(document.Form1.nom.value == '' )
{
alert('Veuillez saisir votre nom!');
document.Form1.nom.value=" ";
document.Form1.nom.focus();
}
else
{
if(!verifMail())
{
alert('Veuillez saisir votre mail!');
document.Form1.mail.focus();
return false;
}
else
{
test=true;
}
}
if(test==true)
{
alert("form ok");
}
else
{
alert("form pas ok");
}
}
function verifMail()
{
testm = false ;
testat=false;
a=document.Form1.mail.value;
for (var j=0 ; j < (a.length) ; j++)
{
if (a.charAt(j)=='@')
{
testat=true;
}
if (testat && a.charAt(j)=='.')
{
testm=true;
}
}
return testm;
}
</script>
9 juin 2008 à 15:32