WooCommerce Paya Gateway

  • Unknown's avatar

    The Expiration date on the checkout page needs to be formatted MM/YY, but the box allows for MM/YYYY to be entered. If the format is not entered correctly, it will decline the card. Is there a way to limit the space to only allow 4 digits(MM/YY)? I have reached out to the developer, but sadly no response.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Since the field is currently allowing extra characters and causing declines, the quickest fix is to add a maxlength attribute to the input field, which physically stops the user from typing more than 5 characters (including the slash). If you aren’t comfortable editing the theme’s template files, you can use a free plugin like ‘Code Snippets’ to add a small piece of jQuery that targets the expiration field ID and limits the input to MM/YY. This not only prevents the MM/YYYY error but also provides a better ‘user experience’ because the box simply stops accepting numbers once the correct format is reached, ensuring the data sent to your payment gateway is always in the format it expects.

  • Unknown's avatar

    Hi James, Thanks for taking the time to look over mypost. I do use elementor and am able to add the jquery. Do you happen to have a jquery that would work in this situation? I’m not the best with it.

  • Unknown's avatar

    Maybe I need to modify here?

  • Unknown's avatar

    While the PHP code you found is perfect for catching errors after the user hits ‘Submit,’ the best way to prevent the mistake entirely is with a short jQuery snippet that ‘masks’ the input field. Since you are using Elementor, you can add an HTML widget to your checkout page and paste a script that targets the expiration field’s ID—usually something like #billing_expiry or #card_expiry. This script can automatically add the forward slash as the user types and use a .attr(‘maxlength’, 5) rule to physically block them from entering a 4-digit year. This creates a much smoother experience because it guides the user into the MM/YY format instantly, ensuring the data matches exactly what your validation function and payment gateway are looking for!

  • Unknown's avatar

    I believe this is the correct JQuery script. Does it look accurate?

Log in or create an account to reply