Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable HTML5 form validation in Angular2 apps?

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.

The code looks like this:

<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?

The validation code is yet to be written.

like image 404
Stefan Avatar asked Jan 17 '17 07:01

Stefan


1 Answers

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>
like image 151
Aravind Avatar answered Sep 28 '22 09:09

Aravind