Avatar of Richard Korts
Richard Korts
Flag for United States of America asked on

Radio Button Javascript

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

The form statement:

<form method="POST" action="http://www.rain1.com/new-site/authorize_net.php" 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 (!document.st.ntr[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?

Thanks
JavaScriptHTML

Avatar of undefined
Last Comment
COBOLdinosaur

8/22/2022 - Mon
Richard Korts

ASKER
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.

Thanks
ASKER CERTIFIED SOLUTION
COBOLdinosaur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61