0
votes

I have been reading thru the Stripe documentation and I was unable to find the answer.

I have a form that has the following fields: first name, last name, address, credit card number, cvc, card expiration.

I know the credit card and cvc fields will not have have a name so it does not get posted to the server.

If the user forgets to fill out the entire form (server side validation for the name and address fields), it displays an error and reloads the page with the fields populated with the data the user entered before submitting.

This may not be possible but wanted to ask, is it possible to repopulate the cvc and credit card fields? I obviously could accomplish this if I gave those two fields a name, but that is insecure and not a option.

1
I absolutely would not even TRY to repopulate those fields. Its bad enough Chrome and other browsers do it automatically when a user clicks the back button. But I would not try to make it an explicit action on your behalf.Oberst
Use ajax / javascript validation together with the server-side validation you already have. That will catch most problems for valid users before the form is actually posted. By the way, why is giving the fields a name insecure? I assume the page loads over https.jeroen
@jeroen giving the credit card and cvc fields a name, if I gave those fields a name, it would post the data to the server, and it could get logged in error logs. I was thinking of doing client side validation to cut down on submitting the form for server side validation.Brad

1 Answers

0
votes

There is no way to achieve that, because if you want to repopulate those fields, you have to store that data somewhere, and that's very dangerous. The only way I can think right know would be using cookies, but those are sent to the server too.

What you could do is, if the server displays an error, it could send a page with a simple script window.history.back(). As said on the comment, Chrome and most browsers will repopulate them for you.