#Bruce - Payment Element
1 messages · Page 1 of 1 (latest)
Hi 👋
Triggering form submission is handled by JavaScript code that the user (you in this case) writes. You can restrict it to just a single button click or design it to also react to users hitting enter. But that part is up to you.
Thanks @sacred crypt ! I see, so I need to be able to detect when someone hits the enter key while they have an input inside the PaymentElement focussed then right?
So my page elements look something like this:
<form id="payment-form">
<div id="payment-element">
<!--Stripe.js injects the Payment Element, I beleive this is implemented as an iframe-->
[BEGIN STRIPE-GENERATED CONTENT]
<iframe>
... in here is the form that collects credit card details, this is generated by Stripe, how do I know if someone hits enter while they have an input in here focussed?
</iframe>
[END STRIPE-GENERATED CONTENT]
</div>
<button id="submit">Pay now</button>
</form>
I can't see JavaScript being used to trigger form submission (https://stripe.com/docs/payments/quickstart) yet hitting enter works in the accompanying demo.
What "Accompanying demo" are you referring to?
Sorry, you have to click "Preview" to display it:
In that demo, hitting enter while you have an input focussed works as expected. However in my implementation I linked to above, hitting enter does nothing.
Hmmm... you're right. That is clearly some extra JavaScript we didn't include in the actual code. That's misleading.
I've filed the feedback that we need to ensure the code we provide matches the behavior of the demo.
Great, thanks for your help!
I hope we get that addressed quickly. Sorry for the inconvenience.