如何在Angular2应用程序中禁用HTML5表单验证? [英] How can I disable HTML5 form validation in Angular2 apps?

查看:91
本文介绍了如何在Angular2应用程序中禁用HTML5表单验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,其中包含所需的电子邮件类型的输入。我想在该输入字段上进行自己的自定义验证,以便能够以不同的语言显示错误消息。但是,目前输入字段是通过HTML5验证来评估的。

I have a form that contains an input of type email that is required. I would like to have my own custom validation on that input field in order to be able to show the error message in different languages. However, currently the input field is evaluated by the HTML5 validation.

代码如下所示:

<input [(ngModel)]="user.email" type="email" class="form-control" id="email" name="email" required placeholder="{{'Email'|translate}}">

是否可以禁用它,以便我能够实现自己的验证?

Is it possible to disable that, so that I am able to implement my own validation?

验证码尚未编写。

推荐答案

包含标签但没有验证属性如下

Include tag with no validate attribute as below

<form action="Form" novalidate>
  <input [(ngModel)]="user.email" type="email" class="form-control" id="email" name="email" required placeholder="{{'Email'|translate}}">
  <input type="submit">
</form>

这篇关于如何在Angular2应用程序中禁用HTML5表单验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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