2

I'm using Zurb Foundation's Abide validations for a form. When I render the form, the form has a novalidate attribute. I removed the attribute with

$('#new_user').removeAttr('novalidate')

I refreshed the page, but still unable to submit. I saw that I should add $('#new_user').validate(), but the didn't work either. Instead it added the novalidate back.

$("#new_user").removeAttr('novalidate')

$( ->
  subscription.setupForm()

  subscription =
    setupFrom: ->
      $('#new_user').submit ->
        $('input[type=submit]').attr('disabled', true)
        if $('#card_number').length
          subscription.processCard()
          false
        else
          true

    processCard: ->
      card =
        number: $('#card_number').val()
        cvc: $('#card_code').val()
        expMonth: $('#card_month').val()
        expYear: $('#card_year').val()
      Stripe.createToken(card, subscription.handleStripeResponse)

    handleStripeResponse: (status, response) ->
      if status == 200
        $('#subscription_stripe_card_token').val(response.id)
        $('#new_subscription')[0].submit()
      else
        $('#stripe_error').text(response.error.message)
        $('input[type=submit]').attr('disabled', false)
)

The beginning of the form

= form_for(resource, as: resource_name, url: registration_path(resource_name), data: {abide: true}) do |f|
  = devise_error_messages!
  = hidden_field_tag 'plan', @plan
  .field
    = f.label :name, 'Full name'
    = f.email_field :name, autofocus: true, required: true, pattern: 'name'
    %small.error
      You must enter in your full name
...
duncan
  • 31,401
  • 13
  • 78
  • 99
Patrick
  • 1,410
  • 2
  • 19
  • 37

0 Answers0