Skip to content

Instantly share code, notes, and snippets.

@curtiswilkinson
Created October 12, 2015 02:49
Show Gist options
  • Save curtiswilkinson/25c1bbcc1118d5e38448 to your computer and use it in GitHub Desktop.
Save curtiswilkinson/25c1bbcc1118d5e38448 to your computer and use it in GitHub Desktop.
Making a field mandatory before adding to cart using the "disabled" class on the add to cart button by default
<script type="text/javascript">
if ($('#productextra0').length) {
$('#productextra0').keyup(function(){
if ($('#productextra0').val() != '') {
$('.addtocart').removeClass('disabled');
}
else {
$('.addtocart').addClass('disabled');
}
});
}
else {
$('.addtocart').removeClass('disabled');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment