Generic email validator

后端 未结 10 925
灰色年华
灰色年华 2020-11-30 02:01

I want to create a form where the user will enter his email. I\'d like to validate email format client-side.

Is there any generic email validator in Angular 2?

10条回答
  •  难免孤独
    2020-11-30 02:09

    Also you can use ng2-validation-manager for reactive forms which makes validation match easier:

    this.form = new ValidationManager({
      'email'       : 'required|email',
      'password'    : 'required|rangeLength:8,50'
    });
    

    and the view:

    {{form.getError('email')}}
    {{form.getError('password')}}

提交回复
热议问题