Im trying to insert some jQuery into a gravity forms hook (gform_post_paging) to disable the previous button on a multi-page form. I am getting a jQuery is not defined error. I am sure jQuery is being called so not sure whats going on. The multipage form is using ajax if that matters.
my code:
add_action( 'gform_post_paging_4', 'alert_user', 10, 3 );
function alert_user( $form, $source_page_number, $current_page_number ) {
if ( $current_page_number == 2 ) {
$to = $_POST['input_3'];
$subject = ot_get_option( 'consultant_verification_email_subject' );
$headers = array('Content-Type: text/html; charset=UTF-8');
// get the email content from option tree. We are setting a static value for the code.
// if this code needs to change, it should be updated in gravity forms for now
// @todo: we could randomize this value if we want then check the value using jquery
$body = ot_get_option( 'consultant_verification_email' );
wp_mail( $to, $subject, $body, $headers );
?>
<script type="text/javascript">
alert( 'An email was sent to <?php echo $to; ?> with your verification code. Please enter this code to continue. Should you have failed to receive this email, please click the previous button, confirm your email, and click next again. Should you continue to encounter difficulty, please contact us.' );
</script>
<?php
} else if ( $current_page_number == 3 ) {
// disable the previous button so user cant go through verification steps again
?>
<script type="text/javascript">
jQuery(".gform_previous_button").prop("disabled",true);
</script>
<?
}
}