5

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.

3
  • 4
    Include <form> tag with no validate attribute
    – Aravind
    Jan 17, 2017 at 7:13
  • import only { FormGroup, FormBuilder} from '@angular/forms';
    – S M
    Jan 17, 2017 at 7:19
  • @Aravind thanks, I will accept it as correct answer if you want to post it.
    – Stefan
    Jan 17, 2017 at 7:27

1 Answer 1

8

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.