Jump to content

Newsletter form: add custom check box field

Recommended Posts

  • 1 year later...
  • Replies 2
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Posted (edited)
On 8/13/2024 at 4:44 PM, KatjaScalia said:

I'm looking for a solution, too and hope @tuanphan can help...

Use this code to Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
  var newsLetterForm = $(".newsletter-form-body")[0];
	$(newsLetterForm).find(".newsletter-form-fields-wrapper").after('<input id="checkbox-form" type="checkbox">')
  var buttonSubmit = $(newsLetterForm).find("button")
  
  if($(this).is(':checked')){
    	buttonSubmit.removeClass("disableButton")
    } else {
    	buttonSubmit.addClass("disableButton")
    }
  
  $("#checkbox-form").change(function() {
  	if($(this).is(':checked')){
    	buttonSubmit.removeClass("disableButton")
    } else {
    	buttonSubmit.addClass("disableButton")
    }
	});
});
</script>
<style>
  .sqs-block-newsletter .newsletter-form-button.disableButton {
  background-color: gray!important;
  pointer-events: none;
}
</style>

 

Edited by tuanphan

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.