1

my login page( build with simple form) add by default html attributes for browser validation on email input that chrome doesn't recognize and show "Please match the requested format."

Maybe is Chrome bug(on firefox works), so have tried to disable browser validation with simple form config SimpleForm.html5 and SimpleForm.browser_validations(false by default), restarted rails but remain the same input:

<input autofocus="autofocus" class="string email optional form-control
input-xlarge" id="customer_email" maxlength="255"
name="customer[email]" pattern="\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z"
size="255" type="email">

have tried also to add on form html: {novalidate: true}, same output

finally have tried to add on input_filed :novalidate => true, the html output change to:

<input autofocus="autofocus" class="string email optional form-control
input-xlarge" id="customer_email" maxlength="255"
name="customer[email]" pattern="\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z"
size="255" type="email" novalidate="novalidate">

but browser validation and chrome error is present.

Any idea to resolve?

PS: Use Bootstrap and the login form is from Devise resource.

4

1 回答 1

1

您可以从导致问题的输入元素中删除模式属性。您只需要pattern: false在输入字段上进行设置。

因此,您的输入字段可能如下所示:

<%= f.input_field :email, type: 'email', required: true, autofocus: true, class: 'form-control', pattern: false %>

nil不起作用;它必须是false。)

这在 Rails 4 中对我有用。

于 2014-02-04T17:04:30.790 回答