Bonjour,
Mon problème : je veux que quand aucun des boutons radio n'est sélectionné, il y ait une erreur !
Or là, quand je sélectionne le premier, c'est ok, mais quand je sélectionne le second, il m'affiche quand même l'erreur.
Merci pour votre patience !
<html>
<head>
<title>Vérification d'un formulaire avec objet document</title>
</head>
<body>
<form method="post" action="ok.php" onsubmit="return(check(this));">
<table>
<tr>
<td width="300" height="150" class="contents" valign="top">
Application
<input name="application_name" type="text"
size="30"><br><br>
<input
name="application_type" type="radio" value="0"> Spoken
language<br>
<input
name="application_type" type="radio" value="1"> Written
language<br><br>
<input
type="submit" value="Add"
onclick="verifForm(this.form)"><br><br>
</td>
</tr>
</table>
<br> Description<br> <textarea
rows="6" cols="25" name="application_description"></textarea>
</form>
<script language="JavaScript">
function check(f) {
if(f.application_name.value == 0) {
alert('Error : you didn\'t enter the application\'s name !');
return(false);
}
if ((document.forms[0].elements[0].checked==false)
&& (document.forms[0].elements[1].checked==false)) {
alert('Error : you didn\'t select the application\'s type !');
return(false);
}
if(f.application_description.value == 0) {
alert('Error : you didn\'t enter the application\'s description !');
return(false);
}
return(true);
}
</script>
</body>
</html>