I'm creating a prototype for an Opt-In page, with a checkbox for the actual opt-in, another checkbox to receive a confirmation letter, and a radio group for selecting the delivery method for that letter.
The SUBMIT button is disabled onload. The Opt-in checkbox is the only required element in that when ticked, we should enable the SUBMIT button.
Where i am stumped is how to add a secondary function to the radio group. Meaning: if the user ticks the confirmation letter checkbox, yet doesnt select one of the subsequent radio-buttons, the form is incomplete and therefore the SUBMIT button should be disabled.
I'm afraid for the confirmation letter, i must use this checkbox + radio group (a regulatory requirement [?]).
I've had success in the past with more basic IF/ELSE functions on single form elements. But i'm stumped on how to have multiple arguments (and, "||") within.
As in previous posts, I just need assistance getting past hurdles of syntax. Thanks for reading, suggestions, hints, etc.
TEST PAGE:
http://bit.ly/9I4eZh
HEAD:
Code:
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
// enables/disables or shows/hides element(s) based on user-actions with other element(s)
$("#btn_submit").attr("disabled", true);
$('#check_optin').attr('checked', false);
function check_elements () {
if (
$('#check_optin').is(':checked') ||
$('#check_conflet').is(':checked') ||
$("input[name='del_set']").is(':checked')
)
{$('#btn_submit').removeAttr('disabled');}
else {$("#btn_submit").attr("disabled", true);}
}})
</script>
BODY:
Code:
<p>
<input type="checkbox" id="check_optin" />
<label for="check_optin" class="checkbox"><strong>I would like to opt-out of the service.</strong></label>
</p>
<p>
<input type="checkbox" id="check_conflet" />
<label for="check_conflet" class="checkbox"><strong>Please send a confirmation letter by:</strong></label>
</p>
<p>
<input type="radio" name="del_set" value="email" /> Email<br />
<input type="radio" name="del_set" value="usps" /> First Class Mail<br />
</p>
<button type="submit" id="btn_submit">Submit</button>