You are here: Re: validate button radio in form « PHP Programming Language « IT news, forums, messages
Re: validate button radio in form

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация