Is there any way to validate custom credit card form before processing checkout?
-
Hi,
I am using jQuery Payment that comes bundled with WooCommerce to format and validate fields. The formatting works, but not the validation. Here’s the code I am using in my js file.jQuery(document).ready(function($) { // Format Card Number, Expiry Date and CVV $('#pld-ccnum').payment('formatCardNumber'); $('#pld-ccexp').payment('formatCardExpiry'); $('#pld-cvv').payment('formatCardCVC'); // Validate fields before submitting the checkout form $( 'form.checkout' ).on( 'checkout_place_order', function() { var valid = $.payment.validateCardNumber($("#pld-ccnum").val()); if (!valid) { event.preventDefault(); event.stopPropagation(); $("#pld-ccnum").focus().css({"border-color":"#e54747"}); return false; } }); });
I also tried
$( 'form.checkout' ).submit( function() {
but that didn’t worked either. What I am missing?
- The topic ‘Is there any way to validate custom credit card form before processing checkout?’ is closed to new replies.