Vérifier si des champs sont vides
Voila j'ai lu le tutorial (http://javascript.developpez.com/faq...s#ControleForm)
voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| <html>
<head>
<script>
function valider()
{
var inputList = document.forms['aaa'].elements;
vat alertTxt = "";
for (unInput in inputList){
if(unInput.type=="text"&&unInput.value.length==0){
alertTxt += "Le champ " + unInput.name + " n'a pas été rempli \n";
}
}
alert(alertTxt);
return false;
}
</script>
</head>
<body>
<form action="page.html" method="post" onsubmit="return valider();" name="aaa">
<input type="text">
<input type="submit">
</form>
</body>
</html> |
Je ne comprend pas pourquoi, il n'affiche pas le message d'alert...
Merci d'avance :s