为什么HTML5表单验证允许没有点的邮件? [英] Why does HTML5 form-validation allow emails without a dot?

查看:109
本文介绍了为什么HTML5表单验证允许没有点的邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个非常简单的模型来演示一些HTML5表单验证。但是,我注意到电子邮件验证不会检查地址中的点,也不会检查该点后面的字符。



换句话说,john @ doe被认为是有效的,当它显然不是有效的电子邮件地址时; doe不是域名。



这就是我编写电子邮件字段的方式:

 < input type =emailrequired /> 

这是不够的吗?

检查这个小提琴来看看我的意思。



注意:我知道如何改为通过RegEx模式实现此目的。

解决方案

因为@ b是一个有效的电子邮件地址地址(例如localhost是一个有效的域名)。请参阅 http://en.wikipedia.org/wiki/Email_address#Examples



另外,请记住,您应始终在服务器中进行输入验证。客户端验证应仅用于向用户提供反馈,而不是依赖,因为它可以轻松绕过。


I'm writing a very simple mock-up to demonstrate some HTML5 form-validation. However, I noticed the email validation doesn't check for a dot in the address, nor does it check for characters following said dot.

In other words, "john@doe" is considered valid, when it's clearly not a valid email address; "doe" isn't a domain.

This is how I'm coding my email field:

<input type="email" required />

Is that not enough?

Check this fiddle to see what I mean.

Note: I know how to accomplish this via a RegEx pattern instead. I'm just wondering how someone could get away with using the email type instead.

解决方案

Because a@b is a valid email address (eg localhost is a valid domain). See http://en.wikipedia.org/wiki/Email_address#Examples

Also, keep in mind that you should always do the input validation in server. The client side validation should be only for giving feedback to the user and not be relied on, since it can be easily bypassed.

这篇关于为什么HTML5表单验证允许没有点的邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆