#Chhay Toch-Input validation

1 messages · Page 1 of 1 (latest)

wooden moth
#

👋 happy to help

lost saddle
#

I have done it

#

but it doesn't required the fields

#

in ReactJS

wooden moth
#

on submission if there are errors you would not submit

#

u can listen to the change event on Stripe Elements and look for event.error on the event passed to your event handler to handle input validation.

When a Stripe Element loses focus and the value it contains does not appear to be valid event.error will be populated and contain a code, message, and type which you can use to update the Element's appearance and display the message to the user.

For example, when you provide a partial card number and switch focus to another field event.error will contain the following:

"error": {
"code": "incomplete_number",
"type": "validation_error",
"message": "Your card number is incomplete."
},

#

you could use those events to update a state that says whether the form is valid or not

opal vigil
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!