Topic: Form with one of two radio buttons required |
|
---|---|
Author | Thread |
Paranoid (IV) Inmate From: Sthlm, Sweden |
posted 12-02-2007 10:49
Hi code: <input type="radio" name="payment" Value="PF" >PF <input type="radio" name="payment" Value="BG">BG
code: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function verify() { var themessage = "Please fill in the following fields "; if (document.form.firstname.value=="") { themessage = themessage + " - Förnamn"; } if (document.form.lastname.value=="") { themessage = themessage + " - Efternamn"; } if (document.form.adress.value=="") { themessage = themessage + " - Adress"; } if (document.form.zip.value=="") { themessage = themessage + " - Postnummer"; } if (document.form.city.value=="") { themessage = themessage + " - Ort"; } if (document.form.email.value=="") { themessage = themessage + " - E-mail"; } if (document.form.phone.value=="") { themessage = themessage + " - Telefonnummer"; } if (document.form.approve.checked==false) { themessage = themessage + " - Godkännande"; } //alert if fields are empty and cancel form submit if (themessage == "Please fill in the following fields ") { document.form.submit(); } else { alert(themessage); return false; } } // End --> </script>
code: } if (document.form.payment.checked==false) { themessage = themessage + " - Betalning"; }
|
Paranoid (IV) Inmate From: f(x) |
posted 12-02-2007 11:38
I haven't coded much JS for ages, but this should be what your looking for: code: if (document.form.payment[0].checked==false && document.form.payment[1].checked==false) { themessage = themessage + " - Betalning"; }
|
Paranoid (IV) Inmate From: Sthlm, Sweden |
posted 12-03-2007 09:02
Thanks! |
Obsessive-Compulsive (I) Inmate From: |
posted 01-20-2008 11:54
zavaboy, |