Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created October 16, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/dcafaf00741fcfab5b162ca2edd15700 to your computer and use it in GitHub Desktop.
Save Pebblo/dcafaf00741fcfab5b162ca2edd15700 to your computer and use it in GitHub Desktop.
Example of how you can use jQuery to validate 2 email question fields. This example forces an email question with ID 18 to compare with the system email question, if they don't match you can not submit the form.
<?php // Please do not include the opening PHP tag if you do not already have one
// This adds the JavaScript to the checkout page, it compares an email question (with ID 18)
// to the system email question and confirms they match.
add_action( 'wp_enqueue_scripts', 'tw_ee_comfirm_email_question_match', 11 );
function tw_ee_comfirm_email_question_match() {
wp_add_inline_script(
'single_page_checkout',
"jQuery('.ee-reg-form-attendee-dv').each( function() {
jQuery(this).find('input.ee-reg-qstn-18').attr('equalTo', '#' + jQuery(this).find('input.ee-reg-qstn-email').attr('id'));
});"
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment