form.elements Array In IE vs FireFox Help

H

HugeBob

Hi All,

I'm using the following function to validate a form containing check
boxes. At least one of which must be checked. I call this method in
the form's onsubmit handler thusly: onsubmit="return ValidateForm
(this)". This code works just fine in IE but not in Firefox. In
Firebug, when I attempt to execute form.elements.type == checked it
doesn't seem to like it and continues on. That attribute is valid.
Anyone have any hints as to why this isn't working as in should in FF?

funtion ValidateForm(form)
{
var servicesChecked = false;

for (var i = 0; i < form.elements.length; i++)
{
if (form.elements.type == 'checked')
{
if (form.elements.checked)
{
servicesChecked = true;
break;
}
}
}

return servicesChecked;
}
 
G

Gregor Kofler

HugeBob meinte:
Hi All,

I'm using the following function to validate a form containing check
boxes. At least one of which must be checked. I call this method in
the form's onsubmit handler thusly: onsubmit="return ValidateForm
(this)". This code works just fine in IE but not in Firefox.

Pretty amazing...
funtion ValidateForm(form)
{
var servicesChecked = false;

for (var i = 0; i < form.elements.length; i++)
{
if (form.elements.type == 'checked')


The type is "checkbox".

Gregor
 
H

Huge B.

HugeBob meinte:
I'm using the following function to validate a form containing check
boxes.  At least one of which must be checked.  I call this method in
the form's onsubmit handler thusly: onsubmit="return ValidateForm
(this)".  This code works just fine in IE but not in Firefox.

Pretty amazing...
funtion ValidateForm(form)
{
    var servicesChecked = false;
    for (var i = 0; i < form.elements.length; i++)
    {
        if (form.elements.type == 'checked')


The type is "checkbox".

Gregor

--http://www.gregorkofler.comhttp://web.gregorkofler.com- vxJS, a JS lib in progress


Thanks Gregor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top