Exemple
d'utilisation
<SCRIPT language=JavaScript type=text/javascript>
<!--
var re_date = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
var re_email = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/ ;
var msg = "";
var msg_debut = "Attention,\n";
//====================
function valide() {
//====================
with (document.test) {
t_date = re_date.test(date.value);
t_email = re_email.test(email.value);
}
if (t_email && t_date) msg = "test correct.";
else {
msg = msg_debut;
if (!t_email) msg += "l'adresse email est incorrecte\n" ;
if (!t_date) msg += "la date est incorrecte\n" ;
}
alert(msg);
}
//-->
</SCRIPT>
|