Probleme javascript firefox

Bonjour,
j ai ce script javascript qui vérifie les valeurs entres sur un champ email ce script fonctionne nickel sur ie mais sur firefox ... pour uen fois quelqu'un un a t il une idée j ai utiliser la console d'erreur java sur firefox rien de probant

</script>
<script language="JavaScript">
function verifSelection() {
if(mail_form.zone_email.value == "ok") {
alert("Veuillez entrer votre adresse email");
mail_form.zone_email.focus();
return false;
}
var exp=new RegExp("^[\\w\\-]+(\\.[\\w\\-]+)*@[\\w\\-]+(\\.[\\w\\-]+)*\\.[\\w\\-]{2,}$", "i");
if(mail_form.zone_email.value !="ok" && !exp.test(mail_form.zone_email.value)){
alert("Adresse email non valide ");
mail_form.zone_email.focus();
return false;
}
}
</script>

Merci
Configuration: Windows Vista
Firefox 3.0.10

3 réponses

  1. Re,

    ok, ce n'est pas un problème de javascript mais de programmation en générale ! lol

    Je pense que tu n'a pas bien compris le principe des fonctions et des paramètre !

    Tu as tout bien fais SAUF le morceau suivant : onSubmit="return checkMail(mail)"
    Tu dois juste remplacer mail par document.getElementById('id_de_ta_zone_de_texte").value

    Et ça devrait marcher ! ;)

    A+

    Gaerebut
    1. Re,

      ici :

      onSubmit="return checkMail(mail)"


      Tu as bien modifier le paramètre envoyé ???
      Si tu as laissé mail en paramètre je ne pense pas que ça marche !
      La fonction marche je l'utilise pour 3 sites différents u_u'

      C'est peut-être toi qui ne sais pas t'en servir !

      A+

      Gaerebut
      1. ça ne marche toujours pas

        je suis débutant en java script donc forcement ça vient de moi ....

        tant pis je reviens à mon script d'origine et j'essaye autre chose
    2. Salut,

      essaye celle là, elle marche sur les deux ;)

      function checkMail(mail){
      	var at="@";	
      	var dot=".";
      	var lat=mail.indexOf(at);
      	var lstr=mail.length;
      	var ldot=mail.indexOf(dot);
      	if(mail.indexOf(at)==-1||mail.indexOf(at,(lat+1))!=-1||mail.indexOf(dot,(lat+2))==-1||mail.indexOf(" ")!=-1||mail.indexOf(at)==-1||mail.indexOf(at)==0||mail.indexOf(at)==lstr||mail.indexOf(dot)==-1||mail.indexOf(dot)==0||mail.indexOf(dot)==lstr||mail.substring(lat-1,lat)==dot||mail.substring(lat+1,lat+2)==dot||mail.indexOf(dot)==lstr-1||mail.indexOf(dot)==lstr-2) 
      return false;
              else return true;
      }


      A+

      Gaerebut
      1. desole ca ne fonctionne pas comme ca

        <html><head><title></title><script language="JavaScript">function checkMail(mail){
        var at="@";
        var dot=".";
        var lat=mail.indexOf(at);
        var lstr=mail.length;
        var ldot=mail.indexOf(dot);
        if(mail.indexOf(at)==-1||mail.indexOf(at,(lat+1))!=-1||mail.indexOf(dot,(lat+2))==-1||mail.indexOf(" ")!=-1||mail.indexOf(at)==-1||mail.indexOf(at)==0||mail.indexOf(at)==lstr||mail.indexOf(dot)==-1||mail.indexOf(dot)==0||mail.indexOf(dot)==lstr||mail.substring(lat-1,lat)==dot||mail.substring(lat+1,lat+2)==dot||mail.indexOf(dot)==lstr-1||mail.indexOf(dot)==lstr-2)
        return false;
        else return true;
        }
        </script>
        </head>
        <body>
        <form name="mail_form" method="post" action="forms.php" onSubmit="return checkMail(mail)">

        il envoie le mail quand meme