Apologies ahead of time, jQuery is not my strength.
I am looking to add a simple field to the registration page that requires the user to enter the correct code. If the code does not match it will display an error.
I used the following method to add a checkbox with verification however little stuck on what to change to create a numeric field that can be validated. an example of the verification code would be 1234-4321-3456-1264.
add_action('learndash_registration_form', 'dbc_ld_registration_terms_and_conditions_field');
function dbc_ld_registration_terms_and_conditions_field() {
$message = 'I have read and agree to the <a href="/terms-and-conditions">Terms and Conditions</a>';
?>
<script>
jQuery(function() {
$("#learndash_registerform #wp-submit").attr('disabled', true);
$("#ld_registration_terms_and_conditions").click(function(){
$("#learndash_registerform #wp-submit").attr('disabled', !this.checked);
});
});
</script>
<style>
#learndash_registerform #wp-submit:disabled {
opacity: 0.7;
cursor: not-allowed;
}
</style>
<p class="learndash-registration-field learndash-registration-field-terms_and_conditions"><input type="checkbox" id="ld_registration_terms_and_conditions" style="width:auto;margin-right: 14px;"><label for="ld_registration_terms_and_conditions"><?php echo $message; ?></label> <span class="learndash-required-field">*</span></p>
<?php
}
Appreciate any help that anyone can provide.