-
-
Save joshfeck/6b64009036b964ea6e7bd5ada57eb9c5 to your computer and use it in GitHub Desktop.
Remove JavaScript validation for the email field in EE3. First example requires WordPress 4.5 or greater. See other code example for sites that have WP 4.4 or lower.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
function eethree_jquery_validator_custom(){ | |
wp_add_inline_script( | |
'validation', | |
'jQuery(document).ready(function($){ | |
$(".email").removeClass("required"); | |
$("label[for=\'email\'] em").hide(); | |
});' | |
); | |
} | |
add_action( 'wp_enqueue_scripts', 'eethree_jquery_validator_custom', 50 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* For sites with WP 4.4 or lower. Doesn't use wp_add_inline_script(). | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
function eethree_jquery_validator_custom(){ | |
if( wp_script_is( 'validation', 'done' ) ) { | |
?> | |
<script>jQuery(document).ready(function($){ | |
$(".email").removeClass("required"); | |
$("label[for='email'] em").hide(); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_print_footer_scripts', 'eethree_jquery_validator_custom', 50 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment