Wikiwi Posted February 11, 2022 Report Share Posted February 11, 2022 This is a quick tutorial on how to format user input for credit/debit cards.First, we would need to add Header & Footer on your submission form and uncheck HTML editor. Once, done kindly put the code below inside the Footer. <script> var input = document.getElementById("textfield_ID"); var ctr = 0; input.unsafe = function () { var key = event.keyCode || event.charCode; if (key == 8 || key == 46){ if(input.value.length > 0){ ctr = input.value.length-1; } } else { ctr = input.value.length+1; if(((ctr % 5) == 0) && ctr <19){ input.value += ' '; } } } </script> Once that is done, don't forget to set the maximum character limit for your Credit/Debit card field to 19. This should result to something like this: Kurumi and kpcollier 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.