Build a Monthly Subscription App with Laravel Cashier: Lesson 24 of 36

Stripe Validation

Up Next

Form Validation

Autoplaying in 7 seconds!


The Stripe.card.createToken will pass back errors if there was a problem creating the token. We can get the error message using: response.error.message.

Here's the snippet to grab the errors and show them in the <div class="stripe-errrors"></div>.


Stripe.card.createToken(form, function(status, response) {

  // if theres an error, show it and re-enable the form button
  if (response.error) {
    form.find('.stripe-errors').text(response.error.message).addClass('alert alert-danger');
    form.find('button').prop('disabled', false);
  } else {


Chris Sevilleja

167 posts

Co-founder of Slapping the keyboard until something good happens.