Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Input Type Email

Tags:

html

php

I'm thinking of using the input type="email" to me new site but I have question if would you prefer to use input type text then Check the value by regular expression or use this HTML 5 Email

E-mail: <input type="email" name="usremail" />

Does the HTML input type Email have issue when used(browser or usage)?

like image 888
Bert Avatar asked Feb 22 '12 04:02

Bert


3 Answers

The browser won't do any validation if it doesn't support it. You can use modernizr to detect whether or not it does, and act accordingly. (Like use native HTML5 validation, or instead use something like jQuery validation )

According to http://dev.w3.org/html5/markup/input.email.html, the input email uses this regex to verify it is an email:

/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

You should be validating these things server side as well anyway.

like image 187
Vigrond Avatar answered Sep 29 '22 20:09

Vigrond


You can use html5 email to validate but it only checks for XXXX@XXXX so that's a valid email lol

for me at least I would say just use jquery validate and always to server side validation

it won't hurt to use the email type as browsers that don't support it will convert to text type

you may want to look at modernizr for backward compatiblility

like image 31
mcgrailm Avatar answered Sep 29 '22 19:09

mcgrailm


HTML5 - as you know - is not fully supported by the available browsers , this input type='email' is supported by Chrome , FF , but not supported by IE old versions .. There's a work around solution : you can stay using these HTML5 inputs , and use this JS library to support the other broswers : http://code.google.com/p/webforms2/

like image 22
Ashraf Avatar answered Sep 29 '22 19:09

Ashraf