Skip to content

Instantly share code, notes, and snippets.

@ChildeRoland840
Last active August 31, 2016 20:22
Show Gist options
  • Save ChildeRoland840/7e68003148fa810cc97f to your computer and use it in GitHub Desktop.
Save ChildeRoland840/7e68003148fa810cc97f to your computer and use it in GitHub Desktop.
Agree To Terms Checkbox
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#targets').submit(function() {
var error = 0;
if (!($('#checkboxid').is(':checked'))) {
error = 1
alert("Please Tick the Agree to Terms of Use");
}
if (error) {
return false;
} else {
return true;
}
});
});
</script>
</head>
<body>
<div class="checkbox">
<label for="agree">
<input type="checkbox" name="agree" id="agree" />
I have read, understood, and hereby agree to the <a href="#" target="_blank"><u>Terms and Conditions of Sale</u></a>.
</label>
</div>
<span class="error-agree-ocst">
<div class="alert alert-danger ocst-agree" role="alert">
Please accept the shipping disclaimer.
</div>
</span>
<button class="btn btn-primary btn-checkout btn-lg" type="submit">Continue</button>
<script>
$("#ocst_form").submit(function(e){
if($('#agree').is(':checked')) {
$('#ocst_form').submit();
} else{
e.preventDefault();
$('.error-agree-ocst').fadeIn('slow');
$('.error-agree-ocst').fadeOut('slow');
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment