Posted by Cah Sableng on 03/27/07 13:43
On Mar 27, 7:43 pm, "elia" <jos...@pcl.ch> wrote:
> function verif_champs()
> {
>
> if(document.forml.Genre.value == "")
> {
> alert("Choose the gender!");
> document.forml.Reference.focus();
> return false;
> }
For a multiple elements with same name, the element becomes
collection. It can be accessed like an array. Use some code like:
function verif_champs(f)
{
var z=f.elements['Genre'];
var y=z.length;
while (y--)
{
if (z[y].checked)
{
return true;
}
}
alert('choose genre');
return false;
}
> <form name="forml" method="post" onSubmit="return verif_champs()"
> action="test22.php" >
The form declaration should give parameter to the new function
<form name="forml" method="post" onSubmit="return verif_champs(this)"
action="test22.php" >
HTH
[Back to original message]
|