Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable twitter bootstrap email validation popover?

I have a form field of type email for logging in. We also allow users to log in with their nicknames and phone numbers.

The problem is that Twitter bootstrap automatically blocks the form submit if the format in the email field is not email (doesn't contain say '@').

Is there any way to disable this twitter .js binding on clicking my "Sign in" button?

enter image description here

Been googling around for some 2 hours now and couldn't find any solutions so I would greatly appreciate any answers!

like image 372
necker Avatar asked Apr 25 '14 11:04

necker


2 Answers

Text type is bad UX for email

<input type="text" />

This text type is not bad. But in the mobile web page, this <input> tag will display keyboard for just normal text not email. What did it mean? Mobile phone's keyboard did not show @, so users should swipe keyboard to type @. And they can not use autocomplete. This is bad ux.

Solution

Use novalidate="novalidate" attribute in your <form> tag. This attribute skip validation when submitted. Here's examples.

<form novalidate="novalidate" class="simple_form new_user">
  ...
</form>

If you use rails ERB simple-form, then you can use novalidate like this.

<%= simple_form_for(resource, html: { novalidate: true }) do |f| %>
  ...
<% end %>

References

  • https://developers.google.com/web/fundamentals/design-and-ux/input/forms#html5_input_types
like image 106
Penguin Avatar answered Oct 07 '22 23:10

Penguin


Simply use html without email attribute:

<input type"email" /><!--will block-->
<input type="text" /><!--will not block-->
like image 44
Bhojendra Rauniyar Avatar answered Oct 07 '22 23:10

Bhojendra Rauniyar