Jump to content
Larry Ullman's Book Forums

Not Allowing Dashes And Spaces?

Recommended Posts



I just finished  reading through Larry's excellent stripe.com tutorial.  Though it works great, I did have one question.  In his code, he doesn't allow spaces or dashes in the credit card number.  Might it be more user friendly to strip out the spaces/dashes after the user submits the form in his submit function?



var ccNum = ccNum.replace(/-/g,"");
var ccNum = ccNum.replace(/ /g,"");
Or are there any pitfalls to this approach?
Thank you,
Link to comment
Share on other sites

Thanks for the nice words. I appreciate it. I should clear up my example, however. Although the form says not to use spaces or hyphens, there's nothing in the code preventing them from being used and the Stripe.js library wisely allows for them, too. Your additional code will work, but it's not actually necessary. Sorry for the confusion!

Link to comment
Share on other sites


  • Create New...