我正在对表单使用 Zurb Foundation 的 Abide 验证。当我渲染表单时,表单有一个novalidate
属性。我删除了属性
$('#new_user').removeAttr('novalidate')
我刷新了页面,但仍然无法提交。我看到我应该添加$('#new_user').validate()
,但也没有用。相反,它添加了 novalidate 。
$("#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)
)
表格的开头
= 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
...