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 属性を削除できます。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 に答える