Change custom error message

Change custom error message

I have a form with two unrelated checkboxes and am trying to configure it so that it requires one checkbox to be checked. I accomplished that with the code below, but now need to change the error message so that it doesn't point to the first checkbox and read, "Please check this box if you want to proceed". I'm trying to figure out how to...

a. Change the invalid message to "Please select at least one option to proceed".
b. Possibly not have it point to the first checkbox.

Here's what I have so far:

  1. $( document ).ready(function() {
  2. $('#nurture_topic_insights').on('submit', submitFrm);

  3. var $checkbox = $('.custom-class')
  4. $checkbox.on('change', function(){
  5.   var checked = false;
  6.   
  7.   $checkbox.each(function(){
  8. checked = checked || $(this).is(':checked')
  9.   })
  10.   
  11.   $checkbox.prop('required', !checked)
  12.   $this.setCustomValidity('Please select at least one option to proceed')
  13.   
  14. })
  15. function submitFrm(e) {
  16.   e.preventDefault(); // Prevnts default form submit.
  17. }
  18. });