Created
June 19, 2022 13:32
-
-
Save MasterHans/00a709b6ca03ea5609eea243dc9c98b5 to your computer and use it in GitHub Desktop.
woocomerce - add validation on checkout field blur - out of input in JS
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
add_action( 'wp_footer', 'ybc_javascript_validation' ); | |
function ybc_javascript_validation(){ | |
if( !is_checkout() ) return; | |
?> <script>jQuery(function($){ | |
$('body').on('blur change', '#billing_birthday', function(){ | |
// alert($(this).val()); | |
var formRow = $(this).parents('.form-row'); | |
// if( /\d/.test( $(this).val() ) ) { | |
formRow.addClass('woocommerce-invalid'); | |
// } else { | |
// formRow.addClass('woocommerce-validated'); | |
// } | |
}); | |
});</script> <?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment