I usually work with PHP so sadly don\'t have some basic JS principles down. This is all I want to accomplish--I\'ve seen many posts on this topic but they are usually beyon
You could use:
if(!this.form.checkbox.checked)
{
alert('You must agree to the terms first.');
return false;
}
(demo page).
false
from an inline event handler will prevent the default action from taking place (in this case, submitting the form).!
is the Boolean NOT operator.this
is the submit button because it is the element the event handler is attached to..form
is the form the submit button is in..checkbox
is the control named "checkbox" in that form..checked
is true if the checkbox is checked and false if the checkbox is unchecked.