Radio Button Javascript

I have a form  with a radio button (and of course other fields).

The form statement:

<form method="POST" action="" name="st" onSubmit="return validate_pmnt_form();">

The radio button:

Please note:  Service packages are non refundable and non transferable.&nbsp;&nbsp; <input type="radio" name="ntr" value="y" style="visibility; visible;">&nbsp;&nbsp;  Click to indicate you have read this statement.

The javascript (in function validate_pmnt_form)

if (![0].checked) {
      alert("Please click that you understand the non-refundable & non-transferrable statement.");
                        return false;
If you DO NOT click the radio button, it still submits the form.

What's wrong?

Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
I changed the javascript to:

if(!document.getElementById('ntr_read').checked) {
                        alert("Please click that you understand the non-refundable & non-transferrable statement.");
                        return false;

and gave the radio button an id of ntr_read & it worked.

I'd still like to know why the original did NOT work.

COBOLdinosaurCommented: is not a property of document. probably words, but the correct reference in modern browsers would be


However using the id is more efficient, because of the way the parser organizes the Document Object.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.