的多个属性类型=“电子邮件”不适用于 ASP.Net-Core
在 ASP 下,我们可以将控件与具有成员的模型绑定
public string Contact { get; set; }
,或者直接 或通过相应的 HTML helper
我们也可以使用数据注释而不是在 Razor 页面中隐式声明类型
[EmailAddress]
public string Contact { get; set; }
但是,如果我想输入以逗号分隔的电子邮件地址列表,该怎么办?
无界 HTML5 代码 在最新浏览器下工作是正确的: type="email" 的多个属性不起作用。但是,当我尝试将其绑定到模型时,看起来 EmailAddressAttribute 已应用于模型,并且只能验证一个电子邮件地址
Under ASP we could bound a control with a model which has member
public string Contact { get; set; }
or directly <input type="email" asp-for="item.Contact">
or through corresponding HTML helper
As well we could use Data Annotation instead of implicitly declare type in Razor page
[EmailAddress]
public string Contact { get; set; }
But what to do if I would like to enter the list of email addresses separated by comma?
It is correct that unbounded HTML5 code <input type="email" multiple>
works under latest browsers:
Multiple attribute for type="email" does not work. But when I am trying to bound it to the model it looks like EmailAddressAttribute is applied to the model and only one email address could be validated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就像@pcalkins所说,浏览器不会为你分离它,你必须实现一些拆分电子邮件功能,如下所示
Like @pcalkins said, the browsers will not separate it for you, you have to implement some split emails functionality like so