#Fredo-disable-enter-submit
1 messages · Page 1 of 1 (latest)
Thanks for sharing. This isn't really a Stripe specific issue, as it's just how <form> buttons work. You'll need to find a way to prevent/disable that with JavaScript. Ideas here: https://stackoverflow.com/questions/895171/prevent-users-from-submitting-a-form-by-hitting-enter
I have already tried to block with the form but as soon as I do that, the entry of the customer's credit card information disappears
Why do you want to disable submit on enter? That an anti-pattern really (what if I can't use a mouse?)
my form works only if the user clicks on the button that's why I don't understand, and as the entries are managed by stripe and not by me I don't know how to manage the system
I'm confused. You said you wanted to 'disable the enter button to send the form', but now it doesn't work?
yes indeed when I press the enter button it gives me an error whereas if I press the button manually it works
I won't bother you any longer, I'll try to find a solution (anyway I have no choice 🙂 )
Thanks for your help
@outer cave I think you just need to add type="submit" to your button element
What error?
it does not change anything
What's the actual error you're seeing?
it refreshes the page while passing in my laravel controller
I think you need e.preventDefault() somewhere, but not sure how that works with PHP/Laravel
Ah, it's because you only have a 'click' event listener
You need a keypress event listener, too: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
I'm looking into it, but otherwise I'm thinking of blocking the button until I have all the values (Card / CCV etc) and as soon as the values are present unblock the button
Yep, that sounds like good UX!
but how to detect by your stripe field that all the information are well entered
You'd listen for change events: https://stripe.com/docs/js/element/events/on_change?type=cardElement
That'll return a complete boolean you can check