Question: I'm using Ruby on Rails to make my login form and when trying to log in, or create a new account I get this client-side error that prevents me from POST'ing the form.

![enter image description here](https://i.stack.imgur.com/csZo6.png)

This is the Ruby code I'm using to generate the form View.

```
#account-form
  h2 Create your free account!

  p Signing up is completely free and you can use all of our features.

  = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
    = f.error_notification

    .form-group
      = f.label :email
      = f.input_field :email, class: 'form-control'

    .form-group
      = f.label :password
      = f.input_field :password, required: true, class: 'form-control'

    .form-group
      = f.label :password_confirmation
      = f.input_field :password_confirmation, require: true, class: 'form-control'

    button.btn.btn-default type='submit' Sign up

  = render 'devise/shared/links'

```

That is generating the following HTML (for the input):

```
<input class="string email optional form-control" 
       id="user_email" 
       maxlength="255" 
       name="user[email]" 
       pattern="\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z" 
       size="255" 
       type="text" value="">

```

Why is my valid email causing this validation to trigger? Any suggestions?

Answer: 
By default, devise had a complex regex that validates email.
I suggest you to simplify this regex. Why? <http://davidcel.is/blog/2012/09/06/stop-validating-email-addresses-with-regex/>

It can be done by adding to `config/initializiers/devise.rb` following line:

```
  config.email_regexp = /.+@.+/

```

That's it.
You could take out the 'form control' validation and see if that helps. Validating email addresses with regexp is very complicated, and apparently you don't care that much whether or not they are entering a valid email address, since the email field is optional. I'd take the form control part out and assume good user input or make them validate their email in another way (like responding to an email).